void ddb_gnome_mmkeys_connect_to_dbus() { GError* dbus_error = NULL; GDBusConnection* connection = NULL; connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &dbus_error); if (connection == NULL) { g_warning("%s: could not connect to dbus: %s\n", NAME, dbus_error->message); if (dbus_error) { g_error_free(dbus_error); } } if (plugin.deadbeef->conf_get_int("ddb_gnome_mmkeys.mate", 0) == 1) { plugin.proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.mate.SettingsDaemon", "/org/mate/SettingsDaemon/MediaKeys", "org.mate.SettingsDaemon.MediaKeys", NULL, &dbus_error); } else { plugin.proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.gnome.SettingsDaemon", "/org/gnome/SettingsDaemon/MediaKeys", "org.gnome.SettingsDaemon.MediaKeys", NULL, &dbus_error); } if (plugin.proxy == NULL) { g_warning("%s: dbus: could not sync with SettingsDaemon: %s\n", NAME, dbus_error->message); if (dbus_error) { g_error_free(dbus_error); } } g_dbus_proxy_call(plugin.proxy, "GrabMediaPlayerKeys", g_variant_new("(su)", "DeadBeef", 0), G_DBUS_CALL_FLAGS_NONE, -1, NULL, first_call_complete, NULL); if (dbus_error) { g_error_free(dbus_error); } }
void update_fru_obj(GDBusConnection* connection, object_info* obj_info, uint8_t state) { GDBusProxy *proxy; GError *error; GVariant *parm; GVariant *result; error = NULL; proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, NULL, /* GDBusInterfaceInfo* */ obj_info->bus_name, /* name */ obj_info->path, /* object path */ "org.openbmc.SensorValue", /* interface name */ NULL, /* GCancellable */ &error); g_assert_no_error (error); error = NULL; parm = g_variant_new("(y)",state); result = g_dbus_proxy_call_sync (proxy, "setValue", parm, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); g_assert_no_error (error); }
static GDBusProxy* gtk_application_get_proxy_if_service_present (GDBusConnection *connection, GDBusProxyFlags flags, const gchar *bus_name, const gchar *object_path, const gchar *interface, GError **error) { GDBusProxy *proxy; gchar *owner; proxy = g_dbus_proxy_new_sync (connection, flags, NULL, bus_name, object_path, interface, NULL, error); /* is there anyone actually providing the service? */ owner = g_dbus_proxy_get_name_owner (proxy); if (owner == NULL) { g_clear_object (&proxy); g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER, "The name %s is not owned", bus_name); } else g_free (owner); return proxy; }
static void queue_register_client (void) { GDBusConnection *bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); if (!bus) return; GError *error = NULL; GDBusProxy *proxy = g_dbus_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_NONE, NULL, GNOME_SESSION_DBUS_NAME, GNOME_SESSION_DBUS_OBJECT, GNOME_SESSION_DBUS_INTERFACE, NULL, &error); g_object_unref (bus); if (proxy == NULL) { g_debug ("Could not connect to the Session manager: %s", error->message); g_error_free (error); return; } /* Register the daemon with cinnamon-session */ g_signal_connect (G_OBJECT (proxy), "g-signal", G_CALLBACK (on_session_over), NULL); g_idle_add_full (G_PRIORITY_DEFAULT, do_register_client, proxy, NULL); }
static void force_logout (CsdSmartcardPlugin *plugin) { GDBusProxy *sm_proxy; GError *error; GVariant *res; g_debug ("CsdSmartcardPlugin telling session manager to force logout"); sm_proxy = g_dbus_proxy_new_sync (plugin->priv->bus_connection, 0, NULL, SM_DBUS_NAME, SM_DBUS_PATH, SM_DBUS_INTERFACE, NULL, NULL); error = NULL; res = g_dbus_proxy_call_sync (sm_proxy, "Logout", g_variant_new ("(i)", SM_LOGOUT_MODE_FORCE), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (! res) { g_warning ("CsdSmartcardPlugin Unable to force logout: %s", error->message); g_error_free (error); } else g_variant_unref (res); g_object_unref (sm_proxy); }
void flash_message(GDBusConnection* connection,char* obj_path,char* method, char* error_msg) { GDBusProxy *proxy; GError *error; GVariant *parm = NULL; error = NULL; proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL, /* GDBusInterfaceInfo* */ "org.openbmc.control.Flash", /* name */ obj_path, /* object path */ "org.openbmc.Flash", /* interface name */ NULL, /* GCancellable */ &error); g_assert_no_error(error); error = NULL; if(strcmp(method,"error")==0) { parm = g_variant_new("(s)",error_msg); } g_dbus_proxy_call_sync(proxy, method, parm, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); g_assert_no_error(error); }
/* FIXMEchpe: make this async! */ static GDBusProxy * get_screensaver_proxy (DrWright *dr) { GDBusConnection *connection; GVariant *result; GError *error = NULL; if (dr->screensaver_proxy != NULL) return dr->screensaver_proxy; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); if (connection == NULL) return NULL; dr->screensaver_proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, GNOME_SCREENSAVER_BUS_NAME, GNOME_SCREENSAVER_OBJECT_PATH, GNOME_SCREENSAVER_INTERFACE, NULL, NULL); g_object_unref (connection); return dr->screensaver_proxy; }
int plugin_init (void) { GDBusConnection *bus; GError *error = NULL; const char *bus_name; nm_g_type_init (); g_return_val_if_fail (!gl.proxy, -1); bus_name = getenv ("NM_DBUS_SERVICE_L2TP"); if (!bus_name) bus_name = NM_DBUS_SERVICE_L2TP; gl.log_level = _nm_utils_ascii_str_to_int64 (getenv ("NM_VPN_LOG_LEVEL"), 10, 0, LOG_DEBUG, LOG_NOTICE); gl.log_prefix_token = getenv ("NM_VPN_LOG_PREFIX_TOKEN") ?: "???"; _LOGI ("initializing"); bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (!bus) { _LOGE ("couldn't connect to system bus: %s", error->message); g_error_free (error); return -1; } gl.proxy = g_dbus_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, bus_name, NM_DBUS_PATH_L2TP_PPP, NM_DBUS_INTERFACE_L2TP_PPP, NULL, &error); g_object_unref (bus); if (!gl.proxy) { _LOGE ("couldn't create D-Bus proxy: %s", error->message); g_error_free (error); return -1; } chap_passwd_hook = get_credentials; chap_check_hook = get_chap_check; pap_passwd_hook = get_credentials; pap_check_hook = get_pap_check; #ifdef USE_EAPTLS eaptls_passwd_hook = get_credentials; #endif add_notifier (&phasechange, nm_phasechange, NULL); add_notifier (&ip_up_notifier, nm_ip_up, NULL); add_notifier (&exitnotify, nm_exit_notify, NULL); return 0; }
/* Private DBus proxy creation */ static void _obex_phonebook_access_create_gdbus_proxy(ObexPhonebookAccess *self, const gchar *dbus_service_name, const gchar *dbus_object_path, GError **error) { g_assert(OBEX_PHONEBOOK_ACCESS_IS(self)); self->priv->proxy = g_dbus_proxy_new_sync(session_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dbus_service_name, dbus_object_path, OBEX_PHONEBOOK_ACCESS_DBUS_INTERFACE, NULL, error); if(self->priv->proxy == NULL) return; }
/* Private DBus proxy creation */ static void _cycling_speed_manager_create_gdbus_proxy(CyclingSpeedManager *self, const gchar *dbus_service_name, const gchar *dbus_object_path, GError **error) { g_assert(CYCLING_SPEED_MANAGER_IS(self)); self->priv->proxy = g_dbus_proxy_new_sync(system_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dbus_service_name, dbus_object_path, CYCLING_SPEED_MANAGER_DBUS_INTERFACE, NULL, error); if(self->priv->proxy == NULL) return; }
/* Private DBus proxy creation */ static void _obex_agent_manager_create_gdbus_proxy(ObexAgentManager *self, const gchar *dbus_service_name, const gchar *dbus_object_path, GError **error) { g_assert(OBEX_AGENT_MANAGER_IS(self)); self->priv->proxy = g_dbus_proxy_new_sync(session_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dbus_service_name, dbus_object_path, OBEX_AGENT_MANAGER_DBUS_INTERFACE, NULL, error); if(self->priv->proxy == NULL) return; }
/* Private DBus proxy creation */ static void _obex_synchronization_create_gdbus_proxy(ObexSynchronization *self, const gchar *dbus_service_name, const gchar *dbus_object_path, GError **error) { g_assert(OBEX_SYNCHRONIZATION_IS(self)); self->priv->proxy = g_dbus_proxy_new_sync(session_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dbus_service_name, dbus_object_path, OBEX_SYNCHRONIZATION_DBUS_INTERFACE, NULL, error); if(self->priv->proxy == NULL) return; }
/* Private DBus proxy creation */ static void _heart_rate_manager_create_gdbus_proxy(HeartRateManager *self, const gchar *dbus_service_name, const gchar *dbus_object_path, GError **error) { g_assert(HEART_RATE_MANAGER_IS(self)); self->priv->proxy = g_dbus_proxy_new_sync(system_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dbus_service_name, dbus_object_path, HEART_RATE_MANAGER_DBUS_INTERFACE, NULL, error); if(self->priv->proxy == NULL) return; }
/* Private DBus proxy creation */ static void _obex_object_push_create_gdbus_proxy(ObexObjectPush *self, const gchar *dbus_service_name, const gchar *dbus_object_path, GError **error) { g_assert(OBEX_OBJECT_PUSH_IS(self)); self->priv->proxy = g_dbus_proxy_new_sync(session_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dbus_service_name, dbus_object_path, OBEX_OBJECT_PUSH_DBUS_INTERFACE, NULL, error); if(self->priv->proxy == NULL) return; }
/* Private DBus proxy creation */ static void _proximity_monitor_create_gdbus_proxy(ProximityMonitor *self, const gchar *dbus_service_name, const gchar *dbus_object_path, GError **error) { g_assert(PROXIMITY_MONITOR_IS(self)); self->priv->proxy = g_dbus_proxy_new_sync(system_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dbus_service_name, dbus_object_path, PROXIMITY_MONITOR_DBUS_INTERFACE, NULL, error); if(self->priv->proxy == NULL) return; self->priv->properties = g_object_new(PROPERTIES_TYPE, "DBusType", "system", "DBusServiceName", dbus_service_name, "DBusObjectPath", dbus_object_path, NULL); g_assert(self->priv->properties != NULL); }
/* Private DBus proxy creation */ static void _obex_session_create_gdbus_proxy(ObexSession *self, const gchar *dbus_service_name, const gchar *dbus_object_path, GError **error) { g_assert(OBEX_SESSION_IS(self)); self->priv->proxy = g_dbus_proxy_new_sync(session_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dbus_service_name, dbus_object_path, OBEX_SESSION_DBUS_INTERFACE, NULL, error); if(self->priv->proxy == NULL) return; self->priv->properties = g_object_new(PROPERTIES_TYPE, "DBusType", "session", "DBusServiceName", dbus_service_name, "DBusObjectPath", dbus_object_path, NULL); g_assert(self->priv->properties != NULL); }
/* Private DBus proxy creation */ static void _network_create_gdbus_proxy(Network *self, const gchar *dbus_service_name, const gchar *dbus_object_path, GError **error) { g_assert(NETWORK_IS(self)); self->priv->proxy = g_dbus_proxy_new_sync(system_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, dbus_service_name, dbus_object_path, NETWORK_DBUS_INTERFACE, NULL, error); if(self->priv->proxy == NULL) return; self->priv->properties = g_object_new(PROPERTIES_TYPE, "DBusType", "system", "DBusServiceName", dbus_service_name, "DBusObjectPath", dbus_object_path, NULL); g_assert(self->priv->properties != NULL); }
int plugin_init (void) { GDBusConnection *bus; GError *err = NULL; const char *bus_name; #if !GLIB_CHECK_VERSION (2, 35, 0) g_type_init (); #endif bus_name = getenv ("NM_DBUS_SERVICE_SSTP"); if (!bus_name) bus_name = NM_DBUS_SERVICE_SSTP; g_message ("nm-sstp-ppp-plugin: (%s): initializing", __func__); bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &err); if (!bus) { g_warning ("nm-sstp-pppd-plugin: (%s): couldn't connect to system bus: (%d) %s", __func__, err ? err->code : -1, err && err->message ? err->message : "(unknown)"); g_error_free (err); return -1; } proxy = g_dbus_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, bus_name, NM_DBUS_PATH_SSTP_PPP, NM_DBUS_INTERFACE_SSTP_PPP, NULL, &err); g_object_unref (bus); if (!proxy) { g_warning ("nm-sstp-pppd-plugin: (%s): couldn't create D-Bus proxy: %s", __func__, err->message); g_error_free (err); return -1; } chap_passwd_hook = get_credentials; chap_check_hook = get_chap_check; pap_passwd_hook = get_credentials; pap_check_hook = get_pap_check; snoop_send_hook = nm_snoop_send; add_notifier (&phasechange, nm_phasechange, NULL); add_notifier (&ip_up_notifier, nm_ip_up, NULL); add_notifier (&exitnotify, nm_exit_notify, proxy); return 0; }
static gboolean fu_plugin_thunderbolt_power_bolt_force_power (FuPlugin *plugin, GError **error) { FuPluginData *data = fu_plugin_get_data (plugin); g_autoptr(GDBusConnection) connection = NULL; g_autoptr(GDBusProxy) proxy = NULL; g_autoptr(GUnixFDList) fds = NULL; g_autoptr(GVariant) val = NULL; GVariant *input; input = g_variant_new ("(ss)", "fwupd", /* who */ ""); /* flags */ connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error); if (connection == NULL) return FALSE; proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, NULL, BOLT_DBUS_SERVICE, BOLT_DBUS_PATH, BOLT_DBUS_INTERFACE, NULL, error); if (proxy == NULL) return FALSE; val = g_dbus_proxy_call_with_unix_fd_list_sync (proxy, "ForcePower", input, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &fds, NULL, error); if (val == NULL) return FALSE; if (g_unix_fd_list_get_length (fds) != 1) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "invalid number of file descriptors returned: %d", g_unix_fd_list_get_length (fds)); return FALSE; } data->bolt_fd = g_unix_fd_list_get (fds, 0, NULL); return TRUE; }
static void impl_activate (PeasActivatable *pplugin) { GDBusConnection *bus; RBMMKeysPlugin *plugin; GError *error = NULL; rb_debug ("activating media player keys plugin"); plugin = RB_MMKEYS_PLUGIN (pplugin); g_object_get (plugin, "object", &plugin->shell, NULL); g_object_get (plugin->shell, "shell-player", &plugin->shell_player, NULL); bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (plugin->grab_type == NONE && bus != NULL) { GError *error = NULL; plugin->proxy = g_dbus_proxy_new_sync (bus, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.gnome.SettingsDaemon", "/org/gnome/SettingsDaemon/MediaKeys", "org.gnome.SettingsDaemon.MediaKeys", NULL, &error); if (error != NULL) { g_warning ("Unable to grab media player keys: %s", error->message); g_clear_error (&error); } else { g_dbus_proxy_call (plugin->proxy, "GrabMediaPlayerKeys", g_variant_new ("(su)", "Rhythmbox", 0), G_DBUS_CALL_FLAGS_NONE, -1, NULL, (GAsyncReadyCallback) first_call_complete, plugin); plugin->grab_type = SETTINGS_DAEMON; } } else { g_warning ("couldn't get dbus session bus: %s", error->message); g_clear_error (&error); } #ifdef HAVE_MMKEYS if (plugin->grab_type == NONE && GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { rb_debug ("attempting old-style key grabs"); mmkeys_grab (plugin, TRUE); plugin->grab_type = X_KEY_GRAB; } #endif }
/* Handle position change callbacks */ static void geoclue_client_signal_cb(GDBusProxy *client, gchar *sender_name, gchar *signal_name, GVariant *parameters, gpointer user_data) { location_geoclue2_state_t *state = user_data; /* Only handle LocationUpdated signals */ if (g_strcmp0(signal_name, "LocationUpdated") != 0) { return; } /* Obtain location path */ const gchar *location_path; g_variant_get_child(parameters, 1, "&o", &location_path); /* Obtain location */ GError *error = NULL; GDBusProxy *location = g_dbus_proxy_new_sync( g_dbus_proxy_get_connection(client), G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.GeoClue2", location_path, "org.freedesktop.GeoClue2.Location", NULL, &error); if (location == NULL) { g_printerr(_("Unable to obtain location: %s.\n"), error->message); g_error_free(error); mark_error(state); return; } g_mutex_lock(&state->lock); /* Read location properties */ GVariant *lat_v = g_dbus_proxy_get_cached_property( location, "Latitude"); state->latitude = g_variant_get_double(lat_v); GVariant *lon_v = g_dbus_proxy_get_cached_property( location, "Longitude"); state->longitude = g_variant_get_double(lon_v); state->available = 1; g_mutex_unlock(&state->lock); pipeutils_signal(state->pipe_fd_write); }
static void impl_activate(PeasActivatable *activatable) { XmrMMKeysPlugin *plugin; GDBusConnection *bus; GError *error = NULL; plugin = XMR_MMKEYS_PLUGIN(activatable); plugin->grab_type = NONE; g_object_get(plugin, "object", &plugin->window, NULL); bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error); if (bus == NULL) { xmr_debug("g_bus_get_sync failed: %s", error->message); g_clear_error(&error); } else { plugin->proxy = g_dbus_proxy_new_sync(bus, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.gnome.SettingsDaemon", "/org/gnome/SettingsDaemon/MediaKeys", "org.gnome.SettingsDaemon.MediaKeys", NULL, &error); if (error != NULL) { xmr_debug("Unable to grab media player keys: %s", error->message); } else { g_dbus_proxy_call(plugin->proxy, "GrabMediaPlayerKeys", g_variant_new("(su)", PACKAGE, 0), G_DBUS_CALL_FLAGS_NONE, -1, NULL, (GAsyncReadyCallback)first_call_complete, plugin); plugin->grab_type = SETTINGS_DAEMON; } } #ifdef HAVE_MMKEYS_H if (plugin->grab_type == NONE) { mmkeys_grab(plugin, TRUE); plugin->grab_type = X_KEY_GRAB; } #endif }
int main (int argc, char **argv) { GDBusConnection *bcon; GMainLoop *loop; g_type_init (); bcon = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); bproxy = g_dbus_proxy_new_sync (bcon, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.myapp.JelariServer", "/org/myapp/JelariObject", "org.myapp.JelariInterface", NULL, NULL); g_dbus_proxy_call (bproxy, "HelloWorld", g_variant_new ("(s)", "Wow"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, (GAsyncReadyCallback) mycallback, NULL); g_main_loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(g_main_loop); return 0; }
static void shell_app_usage_init (ShellAppUsage *self) { ShellGlobal *global; char *shell_userdata_dir, *path; GDBusConnection *session_bus; ShellWindowTracker *tracker; ShellAppSystem *app_system; global = shell_global_get (); self->app_usages_for_context = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy); tracker = shell_window_tracker_get_default (); g_signal_connect (tracker, "notify::focus-app", G_CALLBACK (on_focus_app_changed), self); app_system = shell_app_system_get_default (); g_signal_connect (app_system, "app-state-changed", G_CALLBACK (on_app_state_changed), self); session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); self->session_proxy = g_dbus_proxy_new_sync (session_bus, G_DBUS_PROXY_FLAGS_NONE, NULL, /* interface info */ "org.gnome.SessionManager", "/org/gnome/SessionManager/Presence", "org.gnome.SessionManager", NULL, /* cancellable */ NULL /* error */); g_signal_connect (self->session_proxy, "g-signal", G_CALLBACK (session_proxy_signal), self); g_object_unref (session_bus); self->last_idle = 0; self->currently_idle = FALSE; self->enable_monitoring = FALSE; g_object_get (shell_global_get(), "userdatadir", &shell_userdata_dir, NULL), path = g_build_filename (shell_userdata_dir, DATA_FILENAME, NULL); g_free (shell_userdata_dir); self->configfile = g_file_new_for_path (path); g_free (path); restore_from_file (self); self->privacy_settings = g_settings_new(PRIVACY_SCHEMA); g_signal_connect (self->privacy_settings, "changed::" ENABLE_MONITORING_KEY, G_CALLBACK (on_enable_monitoring_key_changed), self); update_enable_monitoring (self); }
static void list_seats (GDBusConnection *connection) { GDBusProxy *proxy; GError *error; GVariant *res; GVariantIter *iter; gchar *path = NULL; proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, NULL, CK_NAME, CK_MANAGER_PATH, CK_MANAGER_INTERFACE, NULL, &error); if (proxy == NULL) { g_print ("error creating proxy, %s", error->message); g_clear_error (&error); return; } error = NULL; res = g_dbus_proxy_call_sync (proxy, "GetSeats", g_variant_new ("()"), G_DBUS_CALL_FLAGS_NONE, 6000, NULL, &error); if (res == NULL) { g_warning ("Failed to get list of seats: %s", error->message); g_clear_error (&error); goto out; } g_variant_get (res, "(ao)", &iter); while (g_variant_iter_next (iter, "o", &path)) { list_sessions (connection, path); } g_variant_iter_free (iter); g_variant_unref (res); out: g_object_unref (proxy); }
static int _CtSgwStopReloadApp(const char *app_name, int is_reload) { GDBusConnection *connection; GDBusProxy *proxy; GError *error = NULL; GVariant *result; gint ret = 0; CtSgwAppStatus_t status; if (!app_name) return -1; g_strlcpy(status.name, app_name, BUFLEN_32); CtSgwGetAppStatus(&status); if (g_strcmp0(status.state, "RUNNING") != 0) { g_printerr("app %s is not running\n", app_name); return 0; } connection = g_bus_get_sync (DBUS_TYPE, NULL, &error); g_assert_no_error(error); proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL, /* GDBusInterfaceInfo */ "com.ctc.appframework1", /* name */ "/com/ctc/appframework1", /* object path */ "com.ctc.appframework1.AppAgent", /* interface */ NULL, /* GCancellable */ &error); g_assert_no_error(error); result = g_dbus_proxy_call_sync(proxy, is_reload ? "Reload" : "Stop", g_variant_new("(s)", app_name), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); g_assert(result != NULL); g_variant_get(result, "(i)", &ret); g_variant_unref(result); g_object_unref (proxy); g_object_unref (connection); return ret; }
static gboolean chassis_reboot(gpointer connection) { int rc = 0; uint8_t gpio = 0; GDBusProxy *proxy; GError *error; GVariant *parm = NULL; GVariant *result = NULL; // The gpio line may flicker during power on/off, so check that the value // is still 0 (checkstopped) and that host is booted in order to reboot rc = gpio_open(&checkstop); if (rc != GPIO_OK) { return FALSE; } rc = gpio_read(&checkstop, &gpio); if (rc != GPIO_OK) { gpio_close(&checkstop); return FALSE; } gpio_close(&checkstop); if ((!gpio) && (is_host_booted(connection))) { printf("Host Checkstop, rebooting host\n"); error = NULL; proxy = g_dbus_proxy_new_sync((GDBusConnection*)connection, G_DBUS_PROXY_FLAGS_NONE, NULL, /* GDBusInterfaceInfo* */ "org.openbmc.control.Chassis", /* name */ "/org/openbmc/control/chassis0", /* object path */ "org.openbmc.control.Chassis", /* interface name */ NULL, /* GCancellable */ &error); g_assert_no_error(error); error = NULL; result = g_dbus_proxy_call_sync(proxy, "reboot", parm, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); g_assert_no_error(error); } return FALSE; }
int main (int argc, char *argv[]) { guint i=0; feed = argv[1]; if (!feed) { g_print("Syntax: %s URL\n", argv[0]); feed = ""; } loop = g_main_loop_new (NULL, FALSE); if (!init_gdbus ()) return -1; g_signal_connect (connection, "closed", G_CALLBACK (connection_closed_cb), NULL); proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, NULL, RSS_DBUS_SERVICE, RSS_DBUS_PATH, RSS_DBUS_INTERFACE, NULL, NULL); evo_running = send_dbus_ping (); while (!evo_running && i<2) { run(EVOLUTION); g_print("Starting evolution...\n"); while (!(evo_running = send_dbus_ping ())) sleep(1); if (evo_running) break; g_timeout_add (EVOLUTION_PING_TIMEOUT, err_evo_cb, GINT_TO_POINTER(i++)); g_main_loop_run(loop); } if (evo_running) { gboolean result = subscribe_feed(feed); g_print("Success:%d\n", result); return result; } return FALSE; }
static gboolean store_init (void) { GError *error = NULL; if (connection && proxy) { return TRUE; } connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (!connection) { g_critical ("Could not connect to the D-Bus session bus, %s", error ? error->message : "no error given."); g_clear_error (&error); return FALSE; } proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, "org.freedesktop.Tracker1", "/org/freedesktop/Tracker1/Status", "org.freedesktop.Tracker1.Status", NULL, &error); if (error) { g_critical ("Could not create proxy on the D-Bus session bus, %s", error ? error->message : "no error given."); g_clear_error (&error); return FALSE; } g_dbus_connection_signal_subscribe (connection, "org.freedesktop.Tracker1", "org.freedesktop.Tracker1.Status", "Progress", "/org/freedesktop/Tracker1/Status", NULL, G_DBUS_SIGNAL_FLAGS_NONE, store_progress, NULL, NULL); return TRUE; }
// Initialize the connection to KWallet static gboolean init_kwallet(backend_kwallet_context_t *context) { GError *error = NULL; // Make a proxy to KWallet. if(context->proxy) g_object_unref(context->proxy); context->proxy = g_dbus_proxy_new_sync(context->connection, G_DBUS_PROXY_FLAGS_NONE, NULL, kwallet_service_name, kwallet_path, kwallet_interface, NULL, &error); if(check_error(error)) { context->proxy = NULL; return FALSE; } // Check KWallet is enabled. GVariant *ret = g_dbus_proxy_call_sync(context->proxy, "isEnabled", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if(!ret) return FALSE; GVariant *child = g_variant_get_child_value(ret, 0); gboolean is_enabled = g_variant_get_boolean(child); g_variant_unref(child); g_variant_unref(ret); if(check_error(error) || !is_enabled) return FALSE; // Get the wallet name. g_free(context->wallet_name); ret = g_dbus_proxy_call_sync(context->proxy, "networkWallet", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); child = g_variant_get_child_value(ret, 0); context->wallet_name = g_variant_dup_string(child, NULL); g_variant_unref(child); g_variant_unref(ret); if(check_error(error) || !context->wallet_name) { context->wallet_name = NULL; // yes, it's stupid. go figure. return FALSE; } return TRUE; }