static void show_network_panel (void) { DBusGConnection *session_bus; GError *error = NULL; DBusGProxy *proxy; session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (connection == NULL) { g_printerr ("Cannot connect to DBus: %s\n", error->message); g_error_free (error); return; } proxy = dbus_g_proxy_new_for_name (session_bus, "com.meego.UX.Shell.Toolbar", "/com/meego/UX/Shell/Toolbar", "com.meego.UX.Shell.Toolbar"); dbus_g_proxy_call_no_reply (proxy, "ShowPanel", G_TYPE_STRING, "network", G_TYPE_INVALID); /* Need to flush because we're out of the main loop by now */ dbus_g_connection_flush (connection); g_object_unref (proxy); }
/* activesyncd entry point */ int main (int argc, char** argv) { DBusGConnection* bus = NULL; DBusGProxy* busProxy = NULL; EasSync* EasSyncObj = NULL; EasCommon* EasCommonObj = NULL; EasMail*EasMailObj = NULL; EasTest* EasTestObj = NULL; GMainLoop* loop = NULL; guint result; GError* error = NULL; #if !GLIB_CHECK_VERSION(2,36,0) g_type_init(); #endif dbus_g_thread_init(); #if 0 g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL, eas_logger, NULL); #endif g_log_set_default_handler (eas_logger, NULL); signal (SIGABRT, &signalHandler); signal (SIGTERM, &signalHandler); signal (SIGINT, &signalHandler); loop = g_main_loop_new (NULL, FALSE); if (loop == NULL) { g_debug ("Error: Couldn't create GMainLoop"); exit (EXIT_FAILURE); } // Give signalHandler() access to the main loop. g_mainloop = loop; //Creating all the GObjects g_debug ("activesyncd Daemon Started"); g_debug ("Creating eas_sync gobject."); EasSyncObj = eas_sync_new(); if (EasSyncObj == NULL) { g_debug ("Error: Failed to create calendar instance"); g_main_loop_quit (loop); exit (EXIT_FAILURE); } g_debug ("Creating common gobject."); EasCommonObj = g_object_new (EAS_TYPE_COMMON , NULL); if (EasCommonObj == NULL) { g_debug ("Error: Failed to create common instance"); g_main_loop_quit (loop); exit (EXIT_FAILURE); } g_debug ("Creating mail gobject."); EasMailObj = eas_mail_new (); if (EasMailObj == NULL) { g_debug ("Error: Failed to create common instance"); g_main_loop_quit (loop); exit (EXIT_FAILURE); } EasTestObj = eas_test_new (); if (NULL == EasTestObj) { g_debug ("Failed to make EasTest instance"); g_main_loop_quit (loop); exit (EXIT_FAILURE); } g_debug ("Connecting to the session DBus"); bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (error != NULL) { g_debug ("Error: Connecting to the session DBus (%s)", error->message); g_clear_error (&error); g_main_loop_quit (loop); exit (EXIT_FAILURE); } g_debug ("Registering the well-known name (%s)", EAS_SERVICE_NAME); busProxy = dbus_g_proxy_new_for_name (bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); if (busProxy == NULL) { g_debug ("Error: Failed to get a proxy for D-Bus"); g_main_loop_quit (loop); exit (EXIT_FAILURE); } dbus_g_proxy_set_default_timeout (busProxy, 1000000); /* register the well-known name.*/ g_debug ("D-Bus RequestName RPC "); if (!dbus_g_proxy_call (busProxy, "RequestName", &error, G_TYPE_STRING, EAS_SERVICE_NAME, G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &result, G_TYPE_INVALID)) { g_debug ("Error: D-Bus RequestName RPC failed (%s)", error->message); g_clear_error (&error); g_main_loop_quit (loop); exit (EXIT_FAILURE); } g_debug ("RequestName returned %d", result); if (result != 1) { g_debug ("Error: Failed to get the primary well-known name"); exit (EXIT_FAILURE); } // Registering sync Gobject dbus_g_connection_register_g_object (bus, EAS_SERVICE_SYNC_OBJECT_PATH, G_OBJECT (EasSyncObj)); // Registering common Gobject dbus_g_connection_register_g_object (bus, EAS_SERVICE_COMMON_OBJECT_PATH, G_OBJECT (EasCommonObj)); // Registering mail Gobject dbus_g_connection_register_g_object (bus, EAS_SERVICE_MAIL_OBJECT_PATH, G_OBJECT (EasMailObj)); dbus_g_connection_register_g_object (bus, EAS_SERVICE_TEST_OBJECT_PATH, G_OBJECT (EasTestObj)); g_debug ("Ready to serve requests"); #ifndef DISABLE_EAS_DAEMON if (daemon (0, 0) != 0) { g_debug ("Failed to daemonize"); } #else g_debug ("Not daemonizing (built with DISABLE_EAS_DAEMON)"); #endif g_main_loop_run (loop); // Clean up g_debug ("Main Cleanup"); g_mainloop = NULL; g_main_loop_unref (loop); // clean up dbus and all its objects if (EasSyncObj) { g_debug ("Unregister and unref EasSyncObj"); dbus_g_connection_unregister_g_object (bus, G_OBJECT (EasSyncObj)); g_object_unref(EasSyncObj); } if (EasCommonObj) { g_debug ("Unregister and unref EasCommonObj"); dbus_g_connection_unregister_g_object (bus, G_OBJECT (EasCommonObj)); g_object_unref(EasCommonObj); } if (EasMailObj) { g_debug ("Unregister and unref EasMailObj"); dbus_g_connection_unregister_g_object (bus, G_OBJECT (EasMailObj)); g_object_unref(EasMailObj); } if (EasTestObj) { g_debug ("Unregister and unref EasTestObj"); dbus_g_connection_unregister_g_object (bus, G_OBJECT (EasTestObj)); g_object_unref(EasTestObj); } if (busProxy) { g_debug ("Unref busProxy"); g_object_unref(busProxy); } if(bus) { g_debug ("Flush and unref DBusConnection bus"); dbus_g_connection_flush (bus); dbus_g_connection_unref(bus); } g_debug ("Exiting main()"); return 0; }