Move GetInterfaces method to Manager interface 07/242807/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Tue, 1 Sep 2020 03:11:34 +0000 (12:11 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Tue, 1 Sep 2020 03:11:34 +0000 (12:11 +0900)
Change-Id: I4e9cd93717a04457f97bf13fc389075a3e5c0e54
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/technology.h
src/connman.conf
src/manager.c
src/technology.c

index b449c8d..d06678e 100755 (executable)
@@ -92,6 +92,8 @@ void connman_technology_driver_unregister(struct connman_technology_driver *driv
 #if defined TIZEN_EXT
 const char *connman_techonology_get_path(enum connman_service_type type);
 void __connman_technology_notify_scan_done(const char *ifname, int val);
+void __connman_technology_append_interfaces(DBusMessageIter *array,
+                               enum connman_service_type type, const char *ifname);
 #endif
 
 #ifdef __cplusplus
index 60e7e82..adff8fa 100644 (file)
@@ -37,7 +37,7 @@
                <check send_destination="net.connman" send_interface="net.connman.Technology" send_member="ScanDevice" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.connman" send_interface="net.connman.Technology" send_member="SetDevicePower" privilege="http://tizen.org/privilege/network.set" />
                <check send_destination="net.connman" send_interface="net.connman.Technology" send_member="SetBSSID" privilege="http://tizen.org/privilege/network.set" />
-               <check send_destination="net.connman" send_interface="net.connman.Technology" send_member="GetInterfaces" privilege="http://tizen.org/privilege/network.get" />
+               <check send_destination="net.connman" send_interface="net.connman.Manager" send_member="GetInterfaces" privilege="http://tizen.org/privilege/network.get" />
                <check send_destination="net.connman" send_interface="net.connman.Technology" send_member="MeshCommands" privilege="http://tizen.org/privilege/network.set" />
        </policy>
 </busconfig>
index 4b351e1..19f62c6 100755 (executable)
@@ -217,6 +217,32 @@ static DBusMessage *get_services(DBusConnection *conn,
 }
 
 #if defined TIZEN_EXT
+static DBusMessage *get_interfaces(DBusConnection *conn, DBusMessage *msg, void *data)
+{
+       DBusMessage *reply;
+       DBusMessageIter iter, array;
+       const char *default_interface = connman_option_get_string("DefaultWifiInterface");
+
+       DBG("DefaultWifiInterface %s", default_interface);
+
+       reply = dbus_message_new_method_return(msg);
+       if (!reply)
+               return NULL;
+
+       dbus_message_iter_init_append(reply, &iter);
+       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+                                       DBUS_TYPE_STRING_AS_STRING, &array);
+
+       dbus_message_iter_append_basic(&array,
+                               DBUS_TYPE_STRING, &default_interface);
+
+       __connman_technology_append_interfaces(&array,
+                       CONNMAN_SERVICE_TYPE_WIFI, default_interface);
+
+       dbus_message_iter_close_container(&iter, &array);
+       return reply;
+}
+
 static DBusMessage *get_default_service(DBusConnection *conn,
                                        DBusMessage *msg, void *data)
 {
@@ -700,6 +726,9 @@ static const GDBusMethodTable manager_methods[] = {
                        NULL, GDBUS_ARGS({ "services", "a(oa{sv})" }),
                        get_services) },
 #if defined TIZEN_EXT
+       { GDBUS_METHOD("GetInterfaces",
+                       NULL, GDBUS_ARGS({ "interface_list", "as" }),
+                       get_interfaces) },
        { GDBUS_METHOD("GetDefaultService",
                        NULL, GDBUS_ARGS({ "service", "oa{sv}" }),
                        get_default_service) },
index b358600..e9e4cd6 100644 (file)
@@ -589,6 +589,37 @@ static void append_devices(DBusMessageIter *iter, void *user_data)
                                DBUS_TYPE_STRING, &str);
        }
 }
+
+void __connman_technology_append_interfaces(DBusMessageIter *array,
+                               enum connman_service_type type, const char *ifname)
+{
+       GSList *list;
+       struct connman_technology *technology = NULL;
+
+       for (list = technology_list; list; list = list->next) {
+               struct connman_technology *local_tech = list->data;
+
+               if (local_tech->type != type)
+                       continue;
+
+               technology = local_tech;
+               break;
+       }
+
+       if (!technology)
+               return;
+
+       for (list = technology->device_list; list; list = list->next) {
+               struct connman_device *device = list->data;
+               const char *str = connman_device_get_string(device, "Interface");
+
+               if (g_strcmp0(ifname, str) == 0)
+                       continue;
+
+               dbus_message_iter_append_basic(array,
+                               DBUS_TYPE_STRING, &str);
+       }
+}
 #endif
 
 static void append_properties(DBusMessageIter *iter,
@@ -1755,45 +1786,6 @@ static DBusMessage *get_max_scan_ssid(DBusConnection *conn, DBusMessage *msg, vo
        return reply;
 }
 
-static DBusMessage *get_interfaces(DBusConnection *conn, DBusMessage *msg, void *data)
-{
-       DBusMessage *reply;
-       DBusMessageIter iter, array;
-       GSList *list;
-       struct connman_technology *technology = data;
-       const char *default_interface = connman_option_get_string("DefaultWifiInterface");
-
-       DBG("technology %p", technology);
-
-       reply = dbus_message_new_method_return(msg);
-       if (!reply)
-               return NULL;
-
-       if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
-               return NULL;
-
-       dbus_message_iter_init_append(reply, &iter);
-       dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
-                                       DBUS_TYPE_STRING_AS_STRING, &array);
-
-       dbus_message_iter_append_basic(&array,
-                               DBUS_TYPE_STRING, &default_interface);
-
-       for (list = technology->device_list; list; list = list->next) {
-               struct connman_device *device = list->data;
-               const char *str = connman_device_get_string(device, "Interface");
-
-               if (g_strcmp0(default_interface, str) == 0)
-                       continue;
-
-               dbus_message_iter_append_basic(&array,
-                                               DBUS_TYPE_STRING, &str);
-       }
-
-       dbus_message_iter_close_container(&iter, &array);
-       return reply;
-}
-
 static int technology_enable_device(struct connman_technology *technology,
                                bool enable_device, const char *ifname, struct connman_device **device_out)
 {
@@ -2497,8 +2489,6 @@ static const GDBusMethodTable technology_methods[] = {
                        get_5ghz_supported) },
        { GDBUS_METHOD("GetMaxScanSsid", NULL, GDBUS_ARGS({ "maxscanssid", "a{sv}" }),
                        get_max_scan_ssid) },
-       { GDBUS_METHOD("GetInterfaces", NULL, GDBUS_ARGS({ "interface_list", "as" }),
-                       get_interfaces) },
        { GDBUS_ASYNC_METHOD("SetDevicePower",
                        GDBUS_ARGS({ "ifname", "s" }, { "value", "b" }),
                        NULL, set_device_power) },