DBusService::~DBusService()
{
+#ifndef SINGLE_THREADING
if (__mainLoop && g_main_loop_is_running(__mainLoop)) {
_I(PURPLE("Stopping the mainloop of '%s'"), __serviceName);
g_main_loop_quit(__mainLoop);
_I("Joining the thread of '%s'", __serviceName);
g_thread_join(__gthread);
}
+#else
+ __release();
+#endif
}
GDBusConnection* DBusService::getConnection()
{
_I("Preparing '%s'", __serviceName);
+#ifndef SINGLE_THREADING
__gthread = g_thread_new(__serviceName, __threadFunc, this);
IF_FAIL_RETURN_TAG(__gthread, false, _E, "Thread creation failed");
+#else
+ _I(CYAN("'%s' runs on the default main loop"), __serviceName);
+ IF_FAIL_RETURN(__init(), false);
+ prepare();
+#endif
+
return true;
}
vtable.get_property = NULL;
vtable.set_property = NULL;
+#ifndef SINGLE_THREADING
__mainContext = g_main_context_new();
IF_FAIL_RETURN_TAG(__mainContext, false, _E, "MainContext creation failed");
__mainLoop = g_main_loop_new(__mainContext, FALSE);
IF_FAIL_RETURN_TAG(__mainLoop, false, _E, "MainLoop creation failed");
+#endif
std::string introspection("<node><interface name='");
introspection += __interface + "'>" + __methodSpecs + "</interface></node>";
if (__nodeInfo)
g_dbus_node_info_unref(__nodeInfo);
+#ifndef SINGLE_THREADING
if (__mainLoop)
g_main_loop_unref(__mainLoop);
if (__mainContext)
g_main_context_unref(__mainContext);
+#endif
}
void DBusService::__onUserNew(GDBusConnection* conn, const gchar* sender,