/** * pk_dbus_get_session: * @dbus: the #PkDbus instance * @sender: the sender, usually got from dbus_g_method_get_dbus() * * Gets the logind or ConsoleKit session for the ID. * * Return value: the session identifier, or %NULL if it could not be obtained **/ gchar * pk_dbus_get_session (PkDbus *dbus, const gchar *sender) { gchar *session = NULL; #ifndef PK_BUILD_SYSTEMD _cleanup_error_free_ GError *error = NULL; #endif guint pid; _cleanup_variant_unref_ GVariant *value = NULL; g_return_val_if_fail (PK_IS_DBUS (dbus), NULL); g_return_val_if_fail (sender != NULL, NULL); /* set in the test suite */ if (g_strcmp0 (sender, ":org.freedesktop.PackageKit") == 0) { g_debug ("using self-check shortcut"); session = g_strdup ("xxx"); goto out; } /* no ConsoleKit? */ if (dbus->priv->proxy_session == NULL) { g_warning ("no ConsoleKit, so cannot get session"); goto out; } /* get pid */ pid = pk_dbus_get_pid (dbus, sender); if (pid == G_MAXUINT) { g_warning ("failed to get PID"); goto out; } /* get session from systemd or ConsoleKit */ #ifdef PK_BUILD_SYSTEMD session = pk_dbus_get_session_systemd (pid); #else /* get session from ConsoleKit */ value = g_dbus_proxy_call_sync (dbus->priv->proxy_session, "GetSessionForUnixProcess", g_variant_new ("(u)", pid), G_DBUS_CALL_FLAGS_NONE, 2000, NULL, &error); if (value == NULL) { g_warning ("Failed to get session for %s: %s", sender, error->message); goto out; } g_variant_get (value, "(o)", &session); #endif out: return session; }
void eog_util_show_file_in_filemanager (GFile *file, GdkScreen *screen) { GDBusProxy *proxy; gboolean done = FALSE; g_return_if_fail (file != NULL); proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, "org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1", NULL, NULL); if (proxy) { gchar *uri = g_file_get_uri (file); gchar *startup_id; GVariant *params, *result; GVariantBuilder builder; g_variant_builder_init (&builder, G_VARIANT_TYPE ("as")); g_variant_builder_add (&builder, "s", uri); /* This seems to be the expected format, as other values cause the filemanager window not to get focus. */ startup_id = g_strdup_printf("_TIME%u", gtk_get_current_event_time()); /* params is floating! */ params = g_variant_new ("(ass)", &builder, startup_id); g_free (startup_id); g_variant_builder_clear (&builder); /* Floating params-GVariant is consumed here */ result = g_dbus_proxy_call_sync (proxy, "ShowItems", params, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); /* Receiving a non-NULL result counts as a successful call. */ if (G_LIKELY (result != NULL)) { done = TRUE; g_variant_unref (result); } g_free (uri); g_object_unref (proxy); } /* Fallback to gtk_show_uri() if launch over DBus is not possible */ if (!done) _eog_util_show_file_in_filemanager_fallback (file, screen); }
static void systemd_daemon_reload(GDBusProxy * proxy, GError ** error) { GVariant *_ret = g_dbus_proxy_call_sync(proxy, "Reload", g_variant_new("()"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (_ret) { g_variant_unref(_ret); } }
static void _onDbusOwnerChange(GObject *gobject, GParamSpec *pspec, gpointer user_data) { GDBusProxy *proxy = G_DBUS_PROXY(gobject); gchar *owner = g_dbus_proxy_get_name_owner(proxy); if (owner == NULL || owner[0] == '\0') { /* We only care about folks coming on the bus. Exit quickly otherwise. */ _info("new dbus owner is empty, nothing to do"); g_free(owner); return; } if (g_strcmp0(owner, DBUS_NAME)) { /* We only care about this address, reject all others. */ _info("new dbus owner is AppMenu.Registrar, nothing to do"); g_free(owner); return; } if (user_data == NULL) { _error("_onDbusOwnerChange invoked with null user_data"); g_free(owner); return; } // _logmsg(LOG_LEVEL_INFO, "new owner '%s'", owner); WndInfo *wi = (WndInfo *) user_data; if (wi->menuPath == NULL) { _error("_onDbusOwnerChange invoked with empty WndInfo"); g_free(owner); return; } char buf[1024]; _printWndInfo(wi, buf, 1024); _logmsg(LOG_LEVEL_INFO, "window: '%s'", buf); GError *error = NULL; g_dbus_proxy_call_sync(wi->registrar, "RegisterWindow", g_variant_new("(uo)", wi->xid, wi->menuPath), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error != NULL) { _logmsg(LOG_LEVEL_ERROR, "Unable to re-register window, error: %s", error->message); g_error_free(error); g_free(owner); return; } // _info("Window has been successfully re-registered"); g_free(owner); }
static bool uninstall_application(GDBusObjectManager* installed, const char* appid) { GList* objects = g_dbus_object_manager_get_objects(installed); GList* l; bool ret = false; for (l = objects; l; l = l->next) { GDBusObject* object = l->data; GDBusInterface* iface = g_dbus_object_get_interface( object, xwalk_installed_app_iface); if (!iface) continue; GDBusProxy* proxy = G_DBUS_PROXY(iface); GVariant* value = g_dbus_proxy_get_cached_property(proxy, "AppID"); if (!value) { g_object_unref(iface); continue; } const char* id; g_variant_get(value, "s", &id); if (g_strcmp0(appid, id)) { g_object_unref(iface); continue; } GError* error = NULL; GVariant* result = g_dbus_proxy_call_sync(proxy, "Uninstall", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (!result) { g_print("Uninstalling application failed: %s\n", error->message); g_error_free(error); g_object_unref(iface); ret = false; goto done; } g_object_unref(iface); ret = true; goto done; } g_print("Application ID '%s' could not be found\n", appid); done: g_list_free_full(objects, g_object_unref); return ret; }
GList * systemd_unit_listall(void) { int lpc = 0; GList *units = NULL; GError *error = NULL; GVariant *out_units = NULL; GVariantIter iter; struct unit_info u; GVariant *_ret = NULL; if (systemd_init() == FALSE) { return NULL; } /* " <method name=\"ListUnits\">\n" \ " <arg name=\"units\" type=\"a(ssssssouso)\" direction=\"out\"/>\n" \ " </method>\n" \ */ _ret = g_dbus_proxy_call_sync(systemd_proxy, "ListUnits", g_variant_new("()"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error || _ret == NULL) { crm_info("Call to ListUnits failed: %s", error ? error->message : "unknown"); g_error_free(error); return NULL; } g_variant_get(_ret, "(@a(ssssssouso))", &out_units); g_variant_iter_init(&iter, out_units); while (g_variant_iter_loop(&iter, "(ssssssouso)", &u.id, &u.description, &u.load_state, &u.active_state, &u.sub_state, &u.following, &u.unit_path, &u.job_id, &u.job_type, &u.job_path)) { char *match = strstr(u.id, ".service"); if (match) { lpc++; match[0] = 0; crm_trace("Got %s[%s] = %s", u.id, u.active_state, u.description); units = g_list_append(units, strdup(u.id)); } } crm_info("Call to ListUnits passed: type '%s' count %d", g_variant_get_type_string(out_units), lpc); g_variant_unref(_ret); return units; }
/** * tracker_miner_manager_pause_for_process: * @manager: a #TrackerMinerManager. * @miner: miner reference * @reason: reason to pause * @cookie: (out) (allow-none): return location for the pause cookie ID * * This function operates exactly the same way as * tracker_miner_manager_pause() with the exception that if the calling * process dies, the pause is resumed. This API is useful for cases * where the calling process has a risk of crashing without resuming * the pause. * * NOTE: If you call g_object_unref() on the @manager before you * intend to resume the pause and it finalizes, it will automatically * resume. * * Returns: %TRUE if the miner was paused successfully, otherwise * %FALSE. * * Since: 0.10.15 **/ gboolean tracker_miner_manager_pause_for_process (TrackerMinerManager *manager, const gchar *miner, const gchar *reason, guint32 *cookie) { GDBusProxy *proxy; const gchar *app_name; GError *error = NULL; GVariant *v; g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE); g_return_val_if_fail (miner != NULL, FALSE); g_return_val_if_fail (reason != NULL, FALSE); proxy = find_miner_proxy (manager, miner, TRUE); if (!proxy) { g_critical ("No D-Bus proxy found for miner '%s'", miner); return FALSE; } /* Find a reasonable app name */ app_name = g_get_application_name (); if (!app_name) { app_name = g_get_prgname (); } if (!app_name) { app_name = "TrackerMinerManager client"; } v = g_dbus_proxy_call_sync (proxy, "PauseForProcess", g_variant_new ("(ss)", app_name, reason), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error) { g_critical ("Could not pause miner '%s': %s", miner, error->message); g_error_free (error); return FALSE; } if (cookie) { g_variant_get (v, "(i)", cookie); } g_variant_unref (v); return TRUE; }
GVariant *obex_object_push_send_file(ObexObjectPush *self, const gchar *sourcefile, GError **error) { g_assert(OBEX_OBJECT_PUSH_IS(self)); GVariant *ret = NULL; GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "SendFile", g_variant_new ("(s)", sourcefile), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (proxy_ret != NULL) return NULL; ret = g_variant_ref_sink(proxy_ret); g_variant_unref(proxy_ret); return ret; }
GVariant *obex_object_push_pull_business_card(ObexObjectPush *self, const gchar *targetfile, GError **error) { g_assert(OBEX_OBJECT_PUSH_IS(self)); GVariant *ret = NULL; GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "PullBusinessCard", g_variant_new ("(s)", targetfile), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (proxy_ret != NULL) return NULL; ret = g_variant_ref_sink(proxy_ret); g_variant_unref(proxy_ret); return ret; }
static GVariant *_set_proxy_property(GDBusProxy *proxy, const char *prop, GVariant *val, GError **err) { GVariant *retv = NULL; retv = g_dbus_proxy_call_sync(proxy, "SetProperty", g_variant_new("(sv)", prop, val), G_DBUS_CALL_FLAGS_NONE, 120000000, NULL, err); return retv; }
static gboolean enroll_start (EnrollData *data, GError **error) { GVariant *result; result = g_dbus_proxy_call_sync (data->device, "EnrollStart", g_variant_new ("(s)", data->finger), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (result == NULL) return FALSE; g_variant_unref (result); return TRUE; }
static gboolean release (EnrollData *data, GError **error) { GVariant *result; result = g_dbus_proxy_call_sync (data->device, "Release", g_variant_new ("()"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (result == NULL) return FALSE; g_variant_unref (result); return TRUE; }
static char * get_session_id (UrfSessionChecker *logind, const char *bus_name) { UrfLogindPrivate *priv = logind->priv; pid_t calling_pid; char *session_id = NULL; GVariant *retval; GError *error; error = NULL; retval = g_dbus_proxy_call_sync (priv->bus_proxy, "GetConnectionUnixProcessID", g_variant_new ("(s)", bus_name), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error) { g_warning("GetConnectionUnixProcessID() failed: %s", error->message); g_error_free (error); goto out; } g_variant_get (retval, "(u)", &calling_pid); g_variant_unref (retval); error = NULL; retval = g_dbus_proxy_call_sync (priv->proxy, "GetSessionByPID", g_variant_new ("(u)", (guint)calling_pid), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error) { g_warning ("Couldn't send GetSessionByPID: %s", error->message); g_error_free (error); session_id = NULL; goto out; } g_variant_get (retval, "(o)", &session_id); session_id = g_strdup (session_id); g_variant_unref (retval); out: return session_id; }
/* boolean Echo() */ gboolean health_device_echo(HealthDevice *self, GError **error) { g_assert(HEALTH_DEVICE_IS(self)); gboolean ret = FALSE; GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "Echo", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (proxy_ret != NULL) return FALSE; proxy_ret = g_variant_get_child_value(proxy_ret, 0); ret = g_variant_get_boolean(proxy_ret); g_variant_unref(proxy_ret); return ret; }
/* object CreateSession(string destination, dict args) */ const gchar *obex_client_create_session(ObexClient *self, const gchar *destination, const GVariant *args, GError **error) { g_assert(OBEX_CLIENT_IS(self)); const gchar *ret = NULL; GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "CreateSession", g_variant_new ("(s@a{sv})", destination, args), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (proxy_ret == NULL) return NULL; proxy_ret = g_variant_get_child_value(proxy_ret, 0); ret = g_variant_get_string(proxy_ret, NULL); g_variant_unref(proxy_ret); return ret; }
/* string Connect(string uuid) */ const gchar *network_connect(Network *self, const gchar *uuid, GError **error) { g_assert(NETWORK_IS(self)); const gchar *ret = NULL; GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "Connect", g_variant_new ("(s)", uuid), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (proxy_ret != NULL) return NULL; proxy_ret = g_variant_get_child_value(proxy_ret, 0); ret = g_variant_get_string(proxy_ret, NULL); g_variant_unref(proxy_ret); return ret; }
static gchar *list_player_names(GError **err) { GString *names_str = g_string_new(""); GError *tmp_error = NULL; GDBusProxy *proxy = g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", NULL, &tmp_error); if (tmp_error != NULL) { g_propagate_error(err, tmp_error); return NULL; } GVariant *reply = g_dbus_proxy_call_sync(proxy, "ListNames", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &tmp_error); if (tmp_error != NULL) { g_propagate_error(err, tmp_error); g_object_unref(proxy); return NULL; } GVariant *reply_child = g_variant_get_child_value(reply, 0); gsize reply_count; const gchar** names = g_variant_get_strv(reply_child, &reply_count); for (int i = 0; i < reply_count; i += 1) { if (g_str_has_prefix(names[i], "org.mpris.MediaPlayer2")) { gchar **bus_name_split = g_strsplit(names[i], ".", 4); g_string_append_printf(names_str, "%s\n", bus_name_split[3]); g_strfreev(bus_name_split); } } g_object_unref(proxy); g_variant_unref(reply); g_variant_unref(reply_child); g_free(names); return g_string_free(names_str, FALSE); }
/** * main: **/ int main (int argc, char *argv[]) { const gchar *packages[] = {"openoffice-clipart", "openoffice-clipart-extras", NULL}; GDBusProxy *proxy = NULL; GError *error = NULL; guint32 xid = 0; GVariant *retval = NULL; /* init the types system */ g_type_init (); /* get a session bus proxy */ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.PackageKit", "/org/freedesktop/PackageKit", "org.freedesktop.PackageKit.Modify", NULL, &error); if (proxy == NULL) { g_warning ("failed: %s", error->message); g_error_free (error); goto out; } /* get the window ID, or use 0 for non-modal */ //xid = GDK_WINDOW_XID (gtk_widget_get_window (dialog)); /* issue the sync request */ retval = g_dbus_proxy_call_sync (proxy, "InstallPackageNames", g_variant_new ("(u^a&ss)", xid, packages, "hide-finished"), G_DBUS_CALL_FLAGS_NONE, -1, /* timeout */ NULL, /* cancellable */ &error); if (retval == NULL) { g_warning ("failed: %s", error->message); g_error_free (error); goto out; } out: if (proxy != NULL) g_object_unref (proxy); if (retval != NULL) g_object_unref (retval); return 0; }
/* uint16 GetSize() */ guint16 obex_phonebook_access_get_size(ObexPhonebookAccess *self, GError **error) { g_assert(OBEX_PHONEBOOK_ACCESS_IS(self)); guint16 ret = 0; GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "GetSize", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (proxy_ret != NULL) return 0; proxy_ret = g_variant_get_child_value(proxy_ret, 0); ret = g_variant_get_uint16(proxy_ret); g_variant_unref(proxy_ret); return ret; }
/* string GetCapabilities() */ const gchar *obex_session_get_capabilities(ObexSession *self, GError **error) { g_assert(OBEX_SESSION_IS(self)); const gchar *ret = NULL; GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "GetCapabilities", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (proxy_ret != NULL) return NULL; proxy_ret = g_variant_get_child_value(proxy_ret, 0); ret = g_variant_get_string(proxy_ret, NULL); g_variant_unref(proxy_ret); return ret; }
/* object CreateChannel(object application, string configuration) */ const gchar *health_device_create_channel(HealthDevice *self, const gchar *application, const gchar *configuration, GError **error) { g_assert(HEALTH_DEVICE_IS(self)); const gchar *ret = NULL; GVariant *proxy_ret = g_dbus_proxy_call_sync(self->priv->proxy, "CreateChannel", g_variant_new ("(os)", application, configuration), G_DBUS_CALL_FLAGS_NONE, -1, NULL, error); if (proxy_ret != NULL) return NULL; proxy_ret = g_variant_get_child_value(proxy_ret, 0); ret = g_variant_get_string(proxy_ret, NULL); g_variant_unref(proxy_ret); return ret; }
static void send_config (GDBusProxy *proxy, GVariant *config, GVariant *ip4config, GVariant *ip6config) { GError *err = NULL; if (!g_dbus_proxy_call_sync (proxy, "SetConfig", g_variant_new ("(*)", config), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err)) { _LOGW ("Could not send configuration information: %s", err->message); g_error_free (err); err = NULL; } if (ip4config) { if (!g_dbus_proxy_call_sync (proxy, "SetIp4Config", g_variant_new ("(*)", ip4config), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err)) { _LOGW ("Could not send IPv4 configuration information: %s", err->message); g_error_free (err); err = NULL; } } if (ip6config) { if (!g_dbus_proxy_call_sync (proxy, "SetIp6Config", g_variant_new ("(*)", ip6config), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err)) { _LOGW ("Could not send IPv6 configuration information: %s", err->message); g_error_free (err); err = NULL; } } }
gboolean set_fingerprint_label (GtkWidget *label1, GtkWidget *label2) { GDBusProxy *device; GVariant *result; GVariantIter *fingers; GError *error = NULL; if (manager == NULL) { create_manager (); if (manager == NULL) { return FALSE; } } device = get_first_device (); if (device == NULL) return FALSE; result = g_dbus_proxy_call_sync (device, "ListEnrolledFingers", g_variant_new ("(s)", ""), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (!result) { if (!g_dbus_error_is_remote_error (error) || strcmp (g_dbus_error_get_remote_error(error), "net.reactivated.Fprint.Error.NoEnrolledPrints") != 0) { g_object_unref (device); return FALSE; } } if (result && g_variant_is_of_type (result, G_VARIANT_TYPE ("(as)"))) g_variant_get (result, "(as)", &fingers); else fingers = NULL; if (fingers == NULL || g_variant_iter_n_children (fingers) == 0) { is_disable = FALSE; gtk_label_set_text (GTK_LABEL (label1), _("Disabled")); gtk_label_set_text (GTK_LABEL (label2), _("Disabled")); } else { is_disable = TRUE; gtk_label_set_text (GTK_LABEL (label1), _("Enabled")); gtk_label_set_text (GTK_LABEL (label2), _("Enabled")); } if (result != NULL) g_variant_unref (result); if (fingers != NULL) g_variant_iter_free (fingers); g_object_unref (device); return TRUE; }
void serverHandleJournal(SoupServer *server, SoupMessage *msg, const char *path, GHashTable *query, SoupClientContext *client, gpointer user_data) { bool ok = false; if(strcmp(path, "/journal/journal.html") == 0) { GDBusProxy *journal = g_dbus_proxy_new_for_bus_sync( G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.laptop.sugar.DataStore", "/org/laptop/sugar/DataStore", "org.laptop.sugar.DataStore", NULL, NULL); GVariant *params = g_variant_new("(a{sv}as)", NULL, NULL); GError *error = NULL; GVariant *result = g_dbus_proxy_call_sync( journal, "find", params, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if(error != NULL) {fprintf(stderr, "error: %d, %d, %s\n", error->domain, error->code, error->message);} if(result != NULL) { soup_message_headers_replace(msg->response_headers, "Content-Type", "text/html"); append(msg, "<html><body>"); GVariant *results = NULL; guint32 count = -1; g_variant_get(result, "(@aa{sv}u)", &results, &count); GVariant *dictionary = NULL; GVariantIter results_iter; g_variant_iter_init(&results_iter, results); while (g_variant_iter_loop(&results_iter, "@a{sv}", &dictionary)) { append(msg, "<p><a href='"); append(msg, lookup(dictionary, "uid", "invalid object id")); append(msg, "'>"); append(msg, lookup(dictionary, "title", "invalid title")); append(msg, "</a></p>"); } append(msg, "</body></html>"); soup_message_set_status(msg, 200); fprintf(stderr, "GET: %s\n", path); ok = true; } } if(!ok) { soup_message_set_status(msg, 404); fprintf(stderr, "ERROR: %s\n", path); } }
static void get_active_connections (GDBusProxy *proxy) { GError *error = NULL; GVariant *ret = NULL, *value = NULL; char **paths; int i; /* Get the ActiveConnections property from the NM Manager object */ ret = g_dbus_proxy_call_sync (proxy, "Get", g_variant_new ("(ss)", NM_DBUS_INTERFACE, "ActiveConnections"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (!ret) { g_dbus_error_strip_remote_error (error); g_warning ("Failed to get ActiveConnections property: %s\n", error->message); g_error_free (error); return; } g_variant_get (ret, "(v)", &value); /* Make sure the ActiveConnections property is the type we expect it to be */ if (!g_variant_is_of_type (value, G_VARIANT_TYPE ("ao"))) { g_warning ("Unexpected type returned getting ActiveConnections: %s", g_variant_get_type_string (value)); goto out; } /* Extract the active connections array from the GValue */ paths = g_variant_dup_objv (value, NULL); if (!paths) { g_warning ("Could not retrieve active connections property"); goto out; } /* And print out the details for each active connection */ for (i = 0; paths[i]; i++) { g_print ("Active connection path: %s\n", paths[i]); get_active_connection_details (paths[i]); } g_strfreev (paths); out: if (value) g_variant_unref (value); if (ret) g_variant_unref (ret); }
Window get_dock_xid() { GDBusProxy *dock_proxy = NULL; GError *error = NULL; GVariant *dock_xid = NULL; dock_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, "com.deepin.dde.dock", "/com/deepin/dde/dock", "com.deepin.dde.dock", NULL, &error); if (error != NULL) { g_warning ("get_dock_xid:dock proxy %s\n", error->message); g_error_free (error); g_object_unref (dock_proxy); return 0; } error = NULL; dock_xid = g_dbus_proxy_call_sync (dock_proxy, "Xid", g_variant_new("()"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error != NULL) { g_warning ("get_dock_xid:Xid %s\n", error->message); g_error_free (error); g_object_unref (dock_proxy); return 0; } if (dock_xid == NULL) { g_warning ("get_dock_xid:Xid is NULL.\n"); g_error_free (error); g_object_unref (dock_proxy); return 0; } error = NULL; g_object_unref (dock_proxy); guint64 xid = 0; g_variant_get(dock_xid, "(t)", &xid); g_message("get_dock_xid:xid:%lu",xid); return xid; }
gboolean gupnp_connman_manager_is_available (void) { GDBusProxy *dbus_proxy; GVariant *ret_values; GError *error = NULL; gboolean ret = FALSE; dbus_proxy = g_dbus_proxy_new_for_bus_sync ( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, NULL, &error); if (error != NULL) { g_warning ("Failed to connect to Connman: %s", error->message); g_error_free (error); return ret; } ret_values = g_dbus_proxy_call_sync ( dbus_proxy, "NameHasOwner", g_variant_new ("(s)", CM_DBUS_CONNMAN_NAME), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error != NULL) { g_warning ("%s.NameHasOwner() failed: %s", DBUS_INTERFACE_DBUS, error->message); g_error_free (error); } else { g_variant_get_child (ret_values, 0, "b", &ret); g_variant_unref (ret_values); } g_object_unref (dbus_proxy); return ret; }
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 GVariant *get_proxy_props(GDBusProxy *proxy) { GError *err = NULL; GVariant *props; props = g_dbus_proxy_call_sync(proxy, "GetProperties", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err); if (err) { g_warning("GetProperties failed: %s\n", err->message); g_error_free(err); return NULL; } return props; }
static void appeared_cb (GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data) { GError *error = NULL; iio_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, "net.hadess.SensorProxy", "/net/hadess/SensorProxy", "net.hadess.SensorProxy", NULL, NULL); g_signal_connect (G_OBJECT (iio_proxy), "g-properties-changed", G_CALLBACK (properties_changed), NULL); /* Accelerometer */ g_dbus_proxy_call_sync (iio_proxy, "ClaimAccelerometer", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); g_assert_no_error (error); /* ALS */ g_dbus_proxy_call_sync (iio_proxy, "ClaimLight", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); g_assert_no_error (error); }