session: Remove use of __connman_service_get_name()
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Mon, 9 May 2011 15:50:10 +0000 (17:50 +0200)
committerDaniel Wagner <daniel.wagner@bmw-carit.de>
Fri, 13 May 2011 13:55:35 +0000 (15:55 +0200)
src/session.c

index c40eef768201c04ac2a1e905fae94e09a7fe04ae..5a0b8a7b9580338e85cfbfb44d9dcd2736fbd4d1 100644 (file)
@@ -63,12 +63,12 @@ struct service_entry {
        /* track why this service was selected */
        enum connman_session_reason reason;
        enum connman_service_state state;
+       const char *name;
        struct connman_service *service;
 };
 
 struct session_info {
        char *bearer;
-       const char *name;
        char *ifname;
        connman_bool_t online;
        connman_bool_t priority;
@@ -342,6 +342,7 @@ static void append_notify(DBusMessageIter *dict,
        struct session_info *info_last = &session->info_last;
        const char *policy;
        struct connman_service *service;
+       const char *name;
 
        if (session->append_all == TRUE ||
                        info->bearer != info_last->bearer) {
@@ -359,20 +360,19 @@ static void append_notify(DBusMessageIter *dict,
                info_last->online = info->online;
        }
 
-       if (session->append_all == TRUE ||
-                       info->name != info_last->name) {
-               connman_dbus_dict_append_basic(dict, "Name",
-                                               DBUS_TYPE_STRING,
-                                               &info->name);
-               info_last->name = info->name;
-       }
-
        if (session->append_all == TRUE ||
                        info->entry != info_last->entry) {
-               if (info->entry == NULL)
+               if (info->entry == NULL) {
+                       name = "";
                        service = NULL;
-               else
+               } else {
+                       name = info->entry->name;
                        service = info->entry->service;
+               }
+
+               connman_dbus_dict_append_basic(dict, "Name",
+                                               DBUS_TYPE_STRING,
+                                               &name);
 
                connman_dbus_dict_append_dict(dict, "IPv4",
                                                append_ipconfig_ipv4,
@@ -755,9 +755,6 @@ static void update_info(struct session_info *info)
                info->bearer = service2bearer(type);
 
                info->online = is_connected(info->entry->state);
-               info->name = __connman_service_get_name(info->entry->service);
-               if (info->name == NULL)
-                       info->name = "";
 
                idx = __connman_service_get_index(info->entry->service);
                info->ifname = connman_inet_ifname(idx);
@@ -766,7 +763,6 @@ static void update_info(struct session_info *info)
        } else {
                info->bearer = "";
                info->online = FALSE;
-               info->name = "";
                info->ifname = "";
        }
 }
@@ -1001,6 +997,7 @@ static struct service_entry *create_service_entry(struct connman_service *servic
 
        entry->reason = CONNMAN_SESSION_REASON_UNKNOWN;
        entry->state = state;
+       entry->name = name;
        entry->service = service;
 
        return entry;