static void pk_backend_search_files_thread(PkBackendJob *job, GVariant *params, gpointer user_data) { gchar **vals, *search; gchar *query; sqlite3_stmt *stmt; PkInfoEnum ret; PkBackendKatjaJobData *job_data = pk_backend_job_get_user_data(job); pk_backend_job_set_status(job, PK_STATUS_ENUM_QUERY); pk_backend_job_set_percentage(job, 0); g_variant_get(params, "(t^a&s)", NULL, &vals); search = g_strjoinv("%", vals); query = sqlite3_mprintf("SELECT (p.name || ';' || p.ver || ';' || p.arch || ';' || r.repo), p.summary, " "p.full_name FROM filelist AS f NATURAL JOIN pkglist AS p NATURAL JOIN repos AS r " "WHERE f.filename LIKE '%%%q%%' GROUP BY f.full_name", search); if ((sqlite3_prepare_v2(job_data->db, query, -1, &stmt, NULL) == SQLITE_OK)) { /* Now we're ready to output all packages */ while (sqlite3_step(stmt) == SQLITE_ROW) { ret = katja_pkg_is_installed((gchar *) sqlite3_column_text(stmt, 2)); if ((ret == PK_INFO_ENUM_INSTALLED) || (ret == PK_INFO_ENUM_UPDATING)) { pk_backend_job_package(job, PK_INFO_ENUM_INSTALLED, (gchar *) sqlite3_column_text(stmt, 0), (gchar *) sqlite3_column_text(stmt, 1)); } else if (ret == PK_INFO_ENUM_INSTALLING) { pk_backend_job_package(job, PK_INFO_ENUM_AVAILABLE, (gchar *) sqlite3_column_text(stmt, 0), (gchar *) sqlite3_column_text(stmt, 1)); } } sqlite3_finalize(stmt); } else { pk_backend_job_error_code(job, PK_ERROR_ENUM_CANNOT_GET_FILELIST, "%s", sqlite3_errmsg(job_data->db)); } sqlite3_free(query); g_free(search); pk_backend_job_set_percentage(job, 100); }
FCITX_EXPORT_API GPtrArray* fcitx_kbd_get_layouts(FcitxKbd* kbd) { GError* error = NULL; GVariant* variant = g_dbus_proxy_call_sync(G_DBUS_PROXY(kbd), "GetLayouts", NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &error ); GPtrArray* array = NULL; if (error) { g_warning("%s", error->message); g_error_free(error); } else if (variant) { array = g_ptr_array_new_with_free_func(fcitx_layout_item_free); GVariantIter *iter; gchar *layout, *kbdvariant, *name, *langcode; g_variant_get(variant, "(a(ssss))", &iter); while (g_variant_iter_next(iter, "(ssss)", &layout, &kbdvariant, &name, &langcode, NULL)) { FcitxLayoutItem* item = g_malloc0(sizeof(FcitxLayoutItem)); item->layout = g_strdup(layout); item->variant = g_strdup(kbdvariant); item->name = g_strdup(name); item->langcode = g_strdup(langcode); g_ptr_array_add(array, item); g_free(name); g_free(kbdvariant); g_free(layout); g_free(langcode); } g_variant_iter_free(iter); } return array; }
static void g_dbus_menu_group_start_ready (GObject *source_object, GAsyncResult *result, gpointer user_data) { GDBusConnection *connection = G_DBUS_CONNECTION (source_object); GDBusMenuGroup *group = user_data; GVariant *reply; g_assert (group->state == GROUP_PENDING); reply = g_dbus_connection_call_finish (connection, result, NULL); if (group->active) { group->state = GROUP_ONLINE; /* If we receive no reply, just act like we got an empty reply. */ if (reply) { GVariantIter *iter; GVariant *items; guint group_id; guint menu_id; g_variant_get (reply, "(a(uuaa{sv}))", &iter); while (g_variant_iter_loop (iter, "(uu@aa{sv})", &group_id, &menu_id, &items)) if (group_id == group->id) g_dbus_menu_group_changed (group, menu_id, 0, 0, items); g_variant_iter_free (iter); } } else g_dbus_menu_group_go_offline (group); if (reply) g_variant_unref (reply); g_dbus_menu_group_unref (group); }
static void cc_sharing_panel_get_host_name_fqdn_done (GDBusConnection *connection, GAsyncResult *res, GetHostNameData *data) { GError *error = NULL; GVariant *variant; const gchar *fqdn; variant = g_dbus_connection_call_finish (connection, res, &error); if (variant == NULL) { /* Avahi service may not be available */ g_debug ("Error calling GetHostNameFqdn: %s", error->message); if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { gchar *hostname; hostname = cc_hostname_entry_get_hostname (CC_HOSTNAME_ENTRY (data->panel->priv->hostname_entry)); cc_sharing_panel_setup_label (data->panel, data->label, hostname); g_free (hostname); } g_free (data); g_error_free (error); return; } g_variant_get (variant, "(&s)", &fqdn); cc_sharing_panel_setup_label (data->panel, data->label, fqdn); g_variant_unref (variant); g_object_unref (connection); g_free (data); }
static void pk_backend_remove_packages_thread(PkBackendJob *job, GVariant *params, gpointer user_data) { gchar **pkg_tokens, **pkg_ids, *cmd_line; guint i; gdouble percent_step; gboolean allow_deps, autoremove; GError *err = NULL; PkBitfield transaction_flags = 0; g_variant_get(params, "(t^a&sbb)", &transaction_flags, &pkg_ids, &allow_deps, &autoremove); if (pk_bitfield_contain(transaction_flags, PK_TRANSACTION_FLAG_ENUM_SIMULATE)) { pk_backend_job_set_status(job, PK_STATUS_ENUM_DEP_RESOLVE); } else { pk_backend_job_set_status(job, PK_STATUS_ENUM_REMOVE); /* Add percent_step percents per removed package */ percent_step = 100.0 / g_strv_length(pkg_ids); for (i = 0; pkg_ids[i]; i++) { pk_backend_job_set_percentage(job, percent_step * i); pkg_tokens = pk_package_id_split(pkg_ids[i]); cmd_line = g_strconcat("/sbin/removepkg ", pkg_tokens[PK_PACKAGE_ID_NAME], NULL); /* Pkgtools return always 0 */ g_spawn_command_line_sync(cmd_line, NULL, NULL, NULL, &err); g_free(cmd_line); g_strfreev(pkg_tokens); if (err) { pk_backend_job_error_code(job, PK_ERROR_ENUM_PACKAGE_FAILED_TO_REMOVE, "%s", err->message); g_error_free(err); return; } pk_backend_job_set_percentage(job, 100); } } }
/* Called when a dbus method is called */ static void service_method_call (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { START_FUNC guint x, y; struct service *service=(struct service *)user_data; if (g_strcmp0(method_name, "show")==0) { #ifdef AT_SPI view_show(service->view, NULL); #else view_show(service->view); #endif } else if (g_strcmp0(method_name, "move")==0) { g_variant_get(parameters, "(uu)", &x, &y); gtk_window_move(GTK_WINDOW(view_window_get(service->view)), x, y); } else if (g_strcmp0(method_name, "hide")==0) view_hide(service->view); else if (g_strcmp0(method_name, "terminate")==0) service->quit(); else flo_error(_("Unknown dbus method called: <%s>"), method_name); g_dbus_method_invocation_return_value(invocation, NULL); END_FUNC }
static void service_name_owner_changed (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) { const gchar *object_name; const gchar *old_owner; const gchar *new_owner; GkdSecretService *self = user_data; /* A peer is connecting or disconnecting from the bus, * remove any client info, when client gone. */ g_variant_get (parameters, "(&s&s&s)", &object_name, &old_owner, &new_owner); if (g_str_equal (new_owner, "") && object_name[0] == ':') g_hash_table_remove (self->clients, object_name); }
static guint gtk_application_impl_dbus_inhibit (GtkApplicationImpl *impl, GtkWindow *window, GtkApplicationInhibitFlags flags, const gchar *reason) { GtkApplicationImplDBus *dbus = (GtkApplicationImplDBus *) impl; GVariant *res; GError *error = NULL; guint cookie; if (dbus->sm_proxy == NULL) return 0; res = g_dbus_proxy_call_sync (dbus->sm_proxy, "Inhibit", g_variant_new ("(s@usu)", dbus->app_id, gtk_application_impl_dbus_get_window_system_id (dbus, window), reason, flags), G_DBUS_CALL_FLAGS_NONE, G_MAXINT, NULL, &error); if (error) { g_warning ("Calling Inhibit failed: %s", error->message); g_error_free (error); return 0; } g_variant_get (res, "(u)", &cookie); g_variant_unref (res); return cookie; }
static void set_time(GVariant *parameters, GDBusMethodInvocation *invocation, const gchar *caller) { gboolean user_interaction; struct method_call_data data; GVariant *variant; gboolean ntp_active; data.set_time.request_time = g_get_monotonic_time(); g_variant_get(parameters, "(xbb)", &data.set_time.requested_time, &data.set_time.relative, &user_interaction); variant = get_ntp_active(); ntp_active = g_variant_get_boolean(variant); g_variant_unref(variant); if (ntp_active) { return_error(invocation, G_DBUS_ERROR_FAILED, "NTP unit is active"); return; } start_auth_check(caller, POLKIT_ACTION_SET_TIME, user_interaction, invocation, finish_set_time, &data); }
static void _method_cb (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, DbusInput *self) { if (g_strcmp0 (method_name, "ControlKey") == 0) { guint keyflag; ClutterEvent *event; ClutterKeyEvent *kevent; g_variant_get (parameters, "(u)", &keyflag); event = clutter_event_new (CLUTTER_KEY_PRESS); kevent = (ClutterKeyEvent *)event; kevent->flags = 0; kevent->source = NULL; kevent->stage = CLUTTER_STAGE (self->stage); kevent->keyval = keyflag; kevent->time = time (NULL); /* KEY PRESS */ clutter_event_put (event); /* KEY RELEASE */ kevent->type = CLUTTER_KEY_RELEASE; clutter_event_put (event); clutter_event_free (event); } g_dbus_method_invocation_return_value (invocation, NULL); }
} int CtSgwGetAppStatus(CtSgwAppStatus_t *app_status) { GDBusConnection *connection; GDBusProxy *proxy; GError *error = NULL; GVariant *result; gchar *str; gint ret = 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, "GetStatus", g_variant_new("(s)", app_status->name), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); g_assert(result != NULL); g_variant_get(result, "(s)", &str); g_strlcpy(app_status->state, str, BUFLEN_16); g_variant_unref (result); g_object_unref (proxy); g_object_unref (connection);
static void backend_get_updates_thread(PkBackendJob *job, GVariant *params, gpointer user_data) { PkBitfield filters; g_variant_get(params, "(t)", &filters); pk_backend_job_set_allow_cancel(job, true); AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job)); if (!apt->init()) { g_debug("Failed to create apt cache"); return; } pk_backend_job_set_status(job, PK_STATUS_ENUM_QUERY); PkgList updates; PkgList blocked; updates = apt->getUpdates(blocked); apt->emitUpdates(updates, filters); apt->emitPackages(blocked, filters, PK_INFO_ENUM_BLOCKED); }
static void name_owner_changed (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) { NamespaceWatcher *watcher = user_data; const gchar *name; const gchar *old_owner; const gchar *new_owner; g_variant_get (parameters, "(&s&s&s)", &name, &old_owner, &new_owner); if (old_owner[0] != '\0') namespace_watcher_name_vanished (watcher, name); if (new_owner[0] != '\0') namespace_watcher_name_appeared (watcher, name, new_owner); }
static void backend_search_groups_thread(PkBackendJob *job, GVariant *params, gpointer user_data) { gchar **search; PkBitfield filters; g_variant_get(params, "(t^a&s)", &filters, &search); AptIntf *apt = static_cast<AptIntf*>(pk_backend_job_get_user_data(job)); if (!apt->init()) { g_debug("Failed to create apt cache"); return; } // It's faster to emit the packages here rather than in the matching part PkgList output; output = apt->getPackagesFromGroup(search); apt->emitPackages(output, filters); pk_backend_job_set_percentage(job, 100); }
static void ol_lyric_source_download_complete_cb (OlLyricSource *source, GVariant *parameters) { OlLyricSourceTask *task; int taskid; int status; GVariantIter *iter; gchar *content = NULL; gsize len = 0; g_variant_get (parameters, "(iiay)", &taskid, &status, &iter); task = ol_lyric_source_get_download_task (source, taskid); if (task == NULL) { ol_errorf ("Download task %d not exist\n", taskid); } else if (status < 0 || status > OL_LYRIC_SOURCE_STATUS_FALIURE) { ol_errorf ("Invalid download status %d\n", status); } else { len = g_variant_iter_n_children (iter); content = g_new (gchar, len + 1); gsize i = 0; while (g_variant_iter_loop (iter, "y", &content[i])) i++; content[len] = '\0'; g_signal_emit (G_OBJECT (task), _download_signals[DOWNLOAD_SIGNAL_COMPLETE], 0, status, content, (guint) len); g_free (content); } g_variant_iter_free (iter); ol_lyric_source_remove_download_task (source, taskid); }
static gboolean ephy_history_service_execute_set_url_zoom_level (EphyHistoryService *self, GVariant *variant, gpointer *result) { char *url_string; double zoom_level; EphyHistoryHost *host; g_variant_get (variant, "(sd)", &url_string, &zoom_level); host = ephy_history_service_get_host_row_from_url (self, url_string); g_free (url_string); g_return_val_if_fail (host != NULL, FALSE); host->zoom_level = zoom_level; ephy_history_service_update_host_row (self, host); ephy_history_service_schedule_commit (self); return TRUE; }
static gboolean method_confplayer(GdbusMedia *object, GDBusMethodInvocation *invocation, GVariant *in_arg, gpointer user_data) { gchar out_buf[BUF_LEN]; guint in_arg1, in_arg2, in_arg3; /** Get the input parameters */ g_variant_get(in_arg, "(uuu)", &in_arg1, &in_arg2, &in_arg3); DBG_LOG ("method confplayer, in arg: %d, %d, %d.\n",in_arg1, in_arg2, in_arg3); if (NULL != method_cb.conf_cb) method_cb.conf_cb (in_arg1, in_arg2, in_arg3, out_buf, user_data); else g_strlcpy (out_buf, "err no cb", BUF_LEN); gdbus_media_complete_open_player(object, invocation, out_buf); return TRUE; }
GIcon * g_vfs_icon_deserialize (GVariant *value) { const gchar *mount_spec_str; const gchar *id_str; GMountSpec *mount_spec; GIcon *icon; if (!g_variant_is_of_type (value, G_VARIANT_TYPE ("(ss)"))) return NULL; g_variant_get (value, "(&s&s)", &mount_spec_str, &id_str); mount_spec = g_mount_spec_new_from_string (mount_spec_str, NULL); if (mount_spec == NULL) return NULL; icon = g_vfs_icon_new (mount_spec, id_str); g_mount_spec_unref (mount_spec); return icon; }
static void Service(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation) { gboolean reply = FALSE; const char *pluginName = Object->Path(); const char *id = NULL; const char *data = NULL; g_variant_get(Parameters, "(&s&s)", &id, &data); if ((pluginName != NULL) && (id != NULL)) { if ((strlen(pluginName) > 9) && (strncmp(pluginName, "/Plugins/", 9) == 0)) { cPlugin *plugin = cPluginManager::GetPlugin(pluginName + 9); if (plugin != NULL) { if (data == NULL) data = ""; if (plugin->Service(id, (void*)data)) reply = TRUE; } } } g_dbus_method_invocation_return_value(Invocation, g_variant_new("(b)", reply)); }
static void on_response_sap_disconnect(GObject *source_object, GAsyncResult *res, gpointer user_data) { GError *error = NULL; GDBusConnection *conn = NULL; GVariant *dbus_result; struct tapi_resp_data *evt_cb_data = user_data; TelSimSapResultCode_t result = TAPI_SIM_SAP_RESULT_CODE_OK; dbg("Func Entrance"); conn = G_DBUS_CONNECTION (source_object); dbus_result = g_dbus_connection_call_finish(conn, res, &error); g_variant_get(dbus_result, "(i)", &result); if (evt_cb_data->cb_fn) { evt_cb_data->cb_fn(evt_cb_data->handle, result, NULL, evt_cb_data->user_data); } free(evt_cb_data); }
static gboolean authorize_method (Daemon *daemon, GDBusMethodInvocation *invocation, gboolean *out_is_authorized, GCancellable *cancellable, GError **error) { const char *sender = g_dbus_method_invocation_get_sender (invocation); gs_unref_variant GVariant *reply = NULL; guint32 uid = 42; reply = g_dbus_proxy_call_sync (daemon->system_bus_proxy, "org.freedesktop.DBus.GetConnectionUnixUser", g_variant_new ("(s)", sender), 0, -1, cancellable, error); if (reply == NULL) return FALSE; g_variant_get (reply, "(u)", &uid); *out_is_authorized = (uid == 0 || auth_uid_is_wheel (uid)); return TRUE; }
static gboolean get_caller_pid (GDBusMethodInvocation *context, GPid *pid) { GVariant *reply; GError *error; guint32 pid_as_int; error = NULL; reply = g_dbus_connection_call_sync (g_dbus_method_invocation_get_connection (context), "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetConnectionUnixProcessID", g_variant_new ("(s)", g_dbus_method_invocation_get_sender (context)), G_VARIANT_TYPE ("(u)"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (reply == NULL) { g_warning ("Could not talk to message bus to find uid of sender %s: %s", g_dbus_method_invocation_get_sender (context), error->message); g_error_free (error); return FALSE; } g_variant_get (reply, "(u)", &pid_as_int); *pid = pid_as_int; g_variant_unref (reply); return TRUE; }
void LauncherEntryRemoteModel::OnDBusNameOwnerChanged(GDBusConnection* connection, const gchar* sender_name, const gchar* object_path, const gchar* interface_name, const gchar* signal_name, GVariant* parameters, gpointer user_data) { auto self = static_cast<LauncherEntryRemoteModel*>(user_data); if (!parameters || self->_entries_by_uri.empty()) return; glib::String name, before, after; g_variant_get(parameters, "(sss)", &name, &before, &after); if (!after || after.Str().empty()) { // Name gone, find and destroy LauncherEntryRemote std::vector<LauncherEntryRemote::Ptr> to_rm; for (auto it = self->_entries_by_uri.begin(); it != self->_entries_by_uri.end(); ++it) { auto entry = it->second; if (entry->DBusName() == name.Str()) { to_rm.push_back(entry); } } for (auto entry : to_rm) { self->RemoveEntry(entry); } } }
static void media_player_key_pressed(GDBusProxy *proxy, const gchar *sender, const gchar *signal, GVariant *parameters, XmrMMKeysPlugin *plugin) { gchar *key; gchar *application; g_variant_get(parameters, "(ss)", &application, &key); if (g_strcmp0(application, PACKAGE)) { xmr_debug("got media player key signal for unexpected application '%s'", application); return; } if (g_strcmp0(key, "Play") == 0 || g_strcmp0(key, "Pause") == 0) { if (xmr_window_playing(plugin->window)) xmr_window_pause(plugin->window); else xmr_window_play(plugin->window); } else if (g_strcmp0(key, "Stop") == 0) { xmr_window_pause(plugin->window); } else if (g_strcmp0(key, "Next") == 0) { xmr_window_play_next(plugin->window); } g_free(key); g_free(application); }
QVariantList QGSettings::choices(const QString &key) const { Q_D(const QGSettings); QVariantList choices; if (!d->valid) return choices; gchar *keyName = Utils::fromCamelCase(key); GSettingsSchemaKey *schemaKey = g_settings_schema_get_key(d->schema, keyName); GVariant *range = g_settings_schema_key_get_range(schemaKey); g_settings_schema_key_unref(schemaKey); g_free(keyName); if (!range) return choices; const gchar *type; GVariant *value; g_variant_get(range, "(&sv)", &type, &value); if (g_str_equal(type, "enum")) { GVariantIter iter; g_variant_iter_init(&iter, value); GVariant *child; while ((child = g_variant_iter_next_value(&iter))) { choices.append(Utils::toQVariant(child)); g_variant_unref(child); } } g_variant_unref(value); g_variant_unref(range); return choices; }
/** * Get information on the proxy. */ static GDBusNodeInfo * g_dbus_proxy_get_node_info (GDBusProxy *proxy) { GError *error; // Error returned by various functions. GVariant *response; // The response from the proxy call. GDBusNodeInfo *info; // Information on the node. const gchar *xml; // XML code for the proxy interface. // Get the introspection data error = NULL; response = g_dbus_proxy_call_sync (proxy, "org.freedesktop.DBus.Introspectable.Introspect", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (response == NULL) { return NULL; } // if (response == NULL) // Get the XML from the introspection data g_variant_get (response, "(&s)", &xml); // Build an object that lets us explore the introspection data. error = NULL; info = g_dbus_node_info_new_for_xml (xml, &error); g_variant_unref (response); if (info == NULL) { return NULL; } // if (info == NULL) // And return that object return info; } // g_dbus_proxy_get_node_info
static void rb_metadata_dbus_load (GVariant *parameters, GDBusMethodInvocation *invocation, ServiceData *svc) { const char *uri; GError *error = NULL; GVariant *response; const char *nothing[] = { NULL }; char **missing_plugins = NULL; char **plugin_descriptions = NULL; const char *mediatype; g_variant_get (parameters, "(&s)", &uri); rb_debug ("loading metadata from %s", uri); rb_metadata_load (svc->metadata, uri, &error); mediatype = rb_metadata_get_media_type (svc->metadata); rb_debug ("metadata load finished (type %s)", mediatype); rb_metadata_get_missing_plugins (svc->metadata, &missing_plugins, &plugin_descriptions); response = g_variant_new ("(^as^asbbbsbisa{iv})", missing_plugins ? missing_plugins : (char **)nothing, plugin_descriptions ? plugin_descriptions : (char **)nothing, rb_metadata_has_audio (svc->metadata), rb_metadata_has_video (svc->metadata), rb_metadata_has_other_data (svc->metadata), mediatype ? mediatype : "", (error == NULL), (error != NULL ? error->code : 0), (error != NULL ? error->message : ""), rb_metadata_dbus_get_variant_builder (svc->metadata)); g_strfreev (missing_plugins); g_strfreev (plugin_descriptions); g_dbus_method_invocation_return_value (invocation, response); }
static void on_properties_changed_check_lock(GDBusProxy *proxy, GVariant *changed, const char *const *invalidated, gpointer user_data) { struct app *app = user_data; gboolean lost_lock = FALSE; if (g_variant_n_children(changed) > 0) { GVariantIter *itr; const char *prop; GVariant *value; g_variant_get(changed, "a{sv}", &itr); while (g_variant_iter_loop(itr, "{&sv}", &prop, &value)) { if (strcmp(prop, "WriteLocked") == 0) { if (!g_variant_get_boolean(value)) lost_lock = TRUE; break; } } g_variant_iter_free(itr); } if (invalidated[0] != NULL) { const char * const *itr; for (itr = invalidated; *itr != NULL; itr++) { if (strcmp(*itr, "WriteLocked") == 0) { lost_lock = TRUE; break; } } } if (lost_lock) { fputs("Lost lock, exit.\n", stderr); app->ret = EXIT_FAILURE; g_main_loop_quit(app->loop); } }
/** * tracker_miner_manager_is_active: * @manager: a #TrackerMinerManager * @miner: miner reference * * Returns the miner's current activity. * * Returns: %TRUE if the @miner is active, otherwise %FALSE. * * Since: 0.8 **/ gboolean tracker_miner_manager_is_active (TrackerMinerManager *manager, const gchar *miner) { TrackerMinerManagerPrivate *priv; GError *error = NULL; gboolean active = FALSE; GVariant *v; g_return_val_if_fail (TRACKER_IS_MINER_MANAGER (manager), FALSE); g_return_val_if_fail (miner != NULL, FALSE); priv = TRACKER_MINER_MANAGER_GET_PRIVATE (manager); v = g_dbus_connection_call_sync (priv->connection, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameHasOwner", g_variant_new ("(s)", miner), (GVariantType *) "(b)", G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error) { g_critical ("Could not check whether miner '%s' is currently active: %s", miner, error ? error->message : "no error given"); g_error_free (error); return FALSE; } g_variant_get (v, "(b)", &active); g_variant_unref (v); return active; }
static gboolean polkit_system_bus_name_exists_sync (PolkitSubject *subject, GCancellable *cancellable, GError **error) { PolkitSystemBusName *name = POLKIT_SYSTEM_BUS_NAME (subject); GDBusConnection *connection; GVariant *result; gboolean ret; ret = FALSE; connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, error); if (connection == NULL) goto out; result = g_dbus_connection_call_sync (connection, "org.freedesktop.DBus", /* name */ "/org/freedesktop/DBus", /* object path */ "org.freedesktop.DBus", /* interface name */ "NameHasOwner", /* method */ g_variant_new ("(s)", name->name), G_VARIANT_TYPE ("(b)"), G_DBUS_CALL_FLAGS_NONE, -1, cancellable, error); if (result == NULL) goto out; g_variant_get (result, "(b)", &ret); g_variant_unref (result); out: if (connection != NULL) g_object_unref (connection); return ret; }