ADD method for launching mdnsresponder 41/65041/2
authorchleun.moon <chleun.moon@samsung.com>
Thu, 7 Apr 2016 04:42:10 +0000 (13:42 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Thu, 7 Apr 2016 05:01:54 +0000 (14:01 +0900)
Change-Id: I19445e439bb028661af53be17c5ab137c2db4a2d
Signed-off-by: cheoleun <chleun.moon@samsung.com>
include/util.h [changed mode: 0755->0644]
interfaces/netconfig-iface-network-state.xml [changed mode: 0755->0644]
packaging/net-config.spec
resources/etc/dbus-1/system.d/net-config.conf [changed mode: 0755->0644]
src/network-state.c [changed mode: 0755->0644]
src/utils/util.c [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 188aae8..e43ec96
@@ -72,6 +72,9 @@ int netconfig_add_route_ipv4(gchar *ip_addr, gchar *subnet, gchar *interface, gi
 int netconfig_del_route_ipv4(gchar *ip_addr, gchar *subnet, gchar *interface, gint address_family);
 
 gboolean handle_launch_direct(Wifi *wifi, GDBusMethodInvocation *context);
+gboolean handle_launch_mdns(Network *object, GDBusMethodInvocation *context);
+gboolean handle_ref_mdns(Network *object, GDBusMethodInvocation *context);
+gboolean handle_unref_mdns(Network *object, GDBusMethodInvocation *context);
 
 gboolean netconfig_send_notification_to_net_popup(const char * noti, const char * data);
 int netconfig_send_message_to_net_popup(const char *title,
old mode 100755 (executable)
new mode 100644 (file)
index e070a59..31860f8
@@ -22,5 +22,8 @@
                </method>
                <method name="CheckGetPrivilege"></method>
                <method name="CheckProfilePrivilege"></method>
+               <method name="LaunchMdns"></method>
+               <method name="RefMdns"></method>
+               <method name="UnrefMdns"></method>
        </interface>
 </node>
\ No newline at end of file
index a9298fc..7c45efd 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          net-config
 Summary:       TIZEN Network Configuration service
-Version:       1.1.64
+Version:       1.1.65
 Release:       2
 Group:         System/Network
 License:       Apache-2.0
old mode 100755 (executable)
new mode 100644 (file)
index f7e997f..ad238e8
@@ -11,6 +11,9 @@
                <check send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="EthernetCableState" privilege="http://tizen.org/privilege/network.get" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="CheckGetPrivilege" privilege="http://tizen.org/privilege/network.get" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="CheckProfilePrivilege" privilege="http://tizen.org/privilege/network.profile" />
+               <allow send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="LaunchMdns"/>
+               <allow send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="RefMdns"/>
+               <allow send_destination="net.netconfig" send_interface="net.netconfig.network" send_member="UnrefMdns"/>
 
                <check send_destination="net.netconfig" send_interface="net.netconfig.network_statistics" send_member="GetWifiLastRxBytes" privilege="http://tizen.org/privilege/network.get" />
                <check send_destination="net.netconfig" send_interface="net.netconfig.network_statistics" send_member="GetWifiLastTxBytes" privilege="http://tizen.org/privilege/network.get" />
old mode 100755 (executable)
new mode 100644 (file)
index 5180cd2..cfba8d9
@@ -1054,6 +1054,12 @@ void state_object_create_and_init(void)
                                G_CALLBACK(handle_ethernet_cable_state), NULL);
        g_signal_connect(netconfigstate, "handle-remove-route",
                                G_CALLBACK(handle_remove_route), NULL);
+       g_signal_connect(netconfigstate, "handle-launch-mdns",
+                               G_CALLBACK(handle_launch_mdns), NULL);
+       g_signal_connect(netconfigstate, "handle-ref-mdns",
+                               G_CALLBACK(handle_ref_mdns), NULL);
+       g_signal_connect(netconfigstate, "handle-unref-mdns",
+                               G_CALLBACK(handle_unref_mdns), NULL);
 
        if (!g_dbus_interface_skeleton_export(interface_network, connection,
                        NETCONFIG_NETWORK_STATE_PATH, NULL)) {
old mode 100755 (executable)
new mode 100644 (file)
index 612e7d1..e339c29
@@ -50,6 +50,7 @@
 #define MAC_ADDRESS_MAX_LEN            18
 
 static gboolean netconfig_device_picker_test = FALSE;
+static int mdnsd_ref_count = 0;
 
 GKeyFile *netconfig_keyfile_load(const char *pathname)
 {
@@ -764,6 +765,7 @@ gboolean handle_launch_direct(Wifi *wifi, GDBusMethodInvocation *context)
                netconfig_error_wifi_direct_failed(context);
                return FALSE;
        }
+
        wifi_complete_launch_direct(wifi, context);
        return TRUE;
 #else
@@ -772,6 +774,68 @@ gboolean handle_launch_direct(Wifi *wifi, GDBusMethodInvocation *context)
 #endif
 }
 
+int execute_mdnsd_script(char* op) {
+       const char *path = "/usr/bin/mdnsresponder-server.sh";
+       char *const args[] = { "mdnsresponder-server.sh", op, NULL };
+       char *const envs[] = { NULL };
+
+       return netconfig_execute_file(path, args, envs);
+}
+
+gboolean handle_launch_mdns(Network *object, GDBusMethodInvocation *context)
+{
+       DBG("Launch mdnsresponder daemon");
+
+       if (mdnsd_ref_count != 0) {
+               ERR("Invalid access");
+               netconfig_error_invalid_parameter(context);
+               return FALSE;
+       }
+
+       if (execute_mdnsd_script("start") < 0) {
+               ERR("Failed to launch mdnsresponder daemon");
+               netconfig_error_invalid_parameter(context);
+               return FALSE;
+       }
+
+       network_complete_launch_mdns(object, context);
+       return TRUE;
+}
+
+gboolean handle_ref_mdns(Network *object, GDBusMethodInvocation *context)
+{
+       mdnsd_ref_count++;
+
+       DBG("Ref mdnsresponder daemon. ref count: %d", mdnsd_ref_count);
+       network_complete_ref_mdns(object, context);
+       return TRUE;
+}
+
+gboolean handle_unref_mdns(Network *object, GDBusMethodInvocation *context)
+{
+       DBG("Unef mdnsresponder daemon");
+
+       if (mdnsd_ref_count <= 0) {
+               ERR("Invalid access");
+               netconfig_error_invalid_parameter(context);
+               return FALSE;
+       }
+
+       mdnsd_ref_count--;
+
+       DBG("Unref mdnsresponder daemon. ref count: %d", mdnsd_ref_count);
+       if (mdnsd_ref_count == 0) {
+               if (execute_mdnsd_script("stop") < 0) {
+                       ERR("Failed to stop mdnsresponder daemon");
+                       netconfig_error_invalid_parameter(context);
+                       return FALSE;
+               }
+       }
+
+       network_complete_unref_mdns(object, context);
+       return TRUE;
+}
+
 gboolean netconfig_send_notification_to_net_popup(const char * noti, const char * ssid)
 {
        int ret = 0;