/** Init function for the cpu-keepalive module * * @param module (not used) * * @return NULL on success, a string with an error message on failure */ const gchar *g_module_check_init(GModule *module) { (void)module; const gchar *status = NULL; if( !(systembus = dbus_connection_get()) ) { status = "mce has no dbus connection"; goto EXIT; } if( !cpu_keepalive_attach_to_dbus() ) { status = "attaching to dbus connection failed"; goto EXIT; } clients = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, client_delete_cb); EXIT: mce_log(LL_NOTICE, "loaded %s, status: %s", module_name, status ?: "ok"); return status; }
/** Install signal and method call message handlers * * @return TRUE on success, or FALSE on failure */ static gboolean cka_dbus_init(void) { gboolean success = FALSE; if( !(cka_dbus_systembus = dbus_connection_get()) ) { goto EXIT; } /* Register signal handling filter */ dbus_connection_add_filter(cka_dbus_systembus, cka_dbus_filter_message_cb, 0, 0); /* Register dbus method call handlers */ mce_dbus_handler_register_array(cka_dbus_handlers); success = TRUE; EXIT: return success; }
/** Start mirroring connman OfflineMode property */ static gboolean xconnman_init(void) { gboolean ack = FALSE; if( !(connman_bus = dbus_connection_get()) ) { mce_log(LL_WARN, "mce has no dbus connection"); goto EXIT; } dbus_connection_add_filter(connman_bus, xconnman_dbus_filter_cb, 0, 0); dbus_bus_add_match(connman_bus, xconnman_prop_change_rule, 0); dbus_bus_add_match(connman_bus, xconnman_name_owner_rule, 0); ack = TRUE; if( !xconnman_check_service() ) ack = FALSE; EXIT: return ack; }
/** Start async UPower device properties query */ static void xup_properties_get_all(const char *path) { DBusConnection *bus = 0; DBusMessage *req = 0; DBusPendingCall *pc = 0; const char *arg = UPOWER_INTERFACE_DEVICE; if( !(bus = dbus_connection_get()) ) goto EXIT; req = dbus_message_new_method_call(UPOWER_SERVICE, path, DBUS_INTERFACE_PROPERTIES, "GetAll"); if( !req ) goto EXIT; if( !dbus_message_append_args(req, DBUS_TYPE_STRING, &arg, DBUS_TYPE_INVALID) ) goto EXIT; if( !dbus_connection_send_with_reply(bus, req, &pc, -1) ) goto EXIT; if( !pc ) goto EXIT; mce_dbus_pending_call_blocks_suspend(pc); if( !dbus_pending_call_set_notify(pc, xup_properties_get_all_cb, strdup(path), free) ) goto EXIT; EXIT: if( pc ) dbus_pending_call_unref(pc); if( req ) dbus_message_unref(req); if( bus ) dbus_connection_unref(bus); }