ClientManager *ctx = (ClientManager*)userData;
GError *error = NULL;
RET_IF(NULL == ctx);
- RET_IF(NULL == ctx->connection);
RET_IF(NULL == ctx->dbusHandle);
ctx->sigHandleChangeMode = g_signal_connect(ctx->dbusHandle, "handle-change-mode",
(gpointer)ctx);
g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(ctx->dbusHandle),
- ctx->connection, MODES_DBUS_OBJPATH, &error);
+ conn, MODES_DBUS_OBJPATH, &error);
if (error) {
ERR("Fail to g_dbus_interface_skeleton_export : %s", error->message);
ClientManager::ClientManager(ModeManager *inModeManager)
{
- GError *error = NULL;
-
- ownerId = g_bus_own_name(G_BUS_TYPE_SYSTEM, MODES_DBUS_INTERFACE,
- G_BUS_NAME_OWNER_FLAGS_REPLACE, ClientManager::onBusAcquired,
- NULL, NULL, this, NULL);
- connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (NULL == connection) {
- ERR("Can not get connection: %s", error? error->message : "unknown");
- if (error) g_error_free(error);
- }
-
dbusHandle = mds_dbus_skeleton_new();
if (NULL == dbusHandle) {
ERR("Can not get mds_bus_skeleton handle");
}
- ownerId = 0;
+ ownerId = g_bus_own_name(G_BUS_TYPE_SYSTEM, MODES_DBUS_INTERFACE,
+ G_BUS_NAME_OWNER_FLAGS_REPLACE, ClientManager::onBusAcquired,
+ NULL, NULL, this, NULL);
+
sigHandleChangeMode = 0;
modeManager = inModeManager;
}
g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(dbusHandle));
g_bus_unown_name(ownerId);
- if (connection) g_object_unref(connection);
- connection = NULL;
-
if (dbusHandle) {
g_object_unref(dbusHandle);
- dbusHandle = NULL;
}
if (modeManager) {
delete(modeManager);
- modeManager = NULL;
}
}
-void ClientManager::changeModeHandler(mdsDbus*interface,
+gboolean ClientManager::changeModeHandler(mdsDbus *object,
GDBusMethodInvocation *invocation,
- const gchar *arg_mode_name, gpointer inUserData)
+ const gchar *arg_mode_name, gpointer userData)
{
- ClientManager *ctx = (ClientManager*)inUserData;
+ ClientManager *ctx = (ClientManager*)userData;
DBG("change-mode method call received!");
DBG("change-mode name %s", arg_mode_name? arg_mode_name : "NULL!!");
- RET_IF(NULL == ctx);
+ RETV_IF(NULL == ctx, true);
if (ctx->modeManager)
ctx->modeManager->applyMode(arg_mode_name);
- if (ctx->dbusHandle)
- mds_dbus_complete_change_mode(ctx->dbusHandle,
- invocation, 0);
+ mds_dbus_complete_change_mode(object,
+ invocation, 0);
+ return true;
}
private:
static void onBusAcquired(GDBusConnection *conn,
const gchar *name, gpointer user_data);
- static void changeModeHandler(mdsDbus *interface,
+ static gboolean changeModeHandler(mdsDbus *object,
GDBusMethodInvocation *invocation,
- const gchar *arg_mode_name, gpointer user_data);
- GDBusConnection *connection;
+ const gchar *arg_mode_name, gpointer userData);
mdsDbus *dbusHandle;
guint ownerId;
ModeManager *modeManager;