Fixed stopping of DBUS service
authorjaviplx <javiplx@gmail.com>
Tue, 5 Oct 2010 00:05:04 +0000 (00:05 +0000)
committerjaviplx <javiplx@gmail.com>
Tue, 5 Oct 2010 00:05:04 +0000 (00:05 +0000)
git-svn-id: file:///svnroot/wifihood/trunk@20 c51dfc6a-5949-4919-9c8e-f207a149c383

wifiscand/wifiscand.c

index 9e9f54e..7351306 100644 (file)
@@ -295,14 +295,14 @@ gint dbus_req_handler(const gchar * interface, const gchar * method,
        appdata->iface.sock = 0;
 #ifdef HAVE_LIBOSSO
         osso_deinitialize(appdata->osso_context);
-#else
-       dbus_deinitialize(appdata->osso_context);
-#endif
         /* Instead of exiting, signaling finish to main loop could be better
         retval->value.s = (gchar *) realloc(retval->value.s,34*sizeof(gchar *));
         snprintf(retval->value.s,34,"Interface moved to original state");
         */
         exit(0);
+#else
+        return OSSO_OK;
+#endif
     }
 
     if ( strcmp(method,"scan")==0 ) {
@@ -335,6 +335,9 @@ gint dbus_req_handler(const gchar * interface, const gchar * method,
 }
 
 #ifndef HAVE_LIBOSSO
+
+dbus_bool_t stopped_service = FALSE;
+
 static DBusObjectPathVTable *vtable = NULL;
 
 int dbus_set_cb_f( DBusConnection *context,
@@ -382,6 +385,9 @@ static DBusHandlerResult handler_wrapper (DBusConnection  *connection,
                                dbus_message_get_member(message),
                                NULL, data, retval);
 
+               if ( strcmp(dbus_message_get_member(message),"stop")==0 )
+                       stopped_service = TRUE;
+
                if ( retval->value.s != NULL ) {
                        DBusMessage *reply = dbus_message_new_method_return (message);
                        if (reply == NULL)
@@ -453,7 +459,7 @@ int main( void ) {
        event_loop = g_main_loop_new(NULL, FALSE);
        g_main_loop_run(event_loop);
 #else
-       while (dbus_connection_read_write_dispatch (osso_context, -1)) {}
+       while (dbus_connection_read_write_dispatch(osso_context, -1) && stopped_service==FALSE) {}
 #endif
 
        /* Deinitialize OSSO */