static void gst_switch_ui_compose_draw (GstElement * overlay, cairo_t * cr, guint64 timestamp, guint64 duration, gpointer data) { GstSwitchUI *ui = GST_SWITCH_UI (data); gint x, y, w, h, n; cairo_set_line_width (cr, 0.6); cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.8); GST_SWITCH_UI_LOCK_FACES (ui); for (n = 0; ui->faces && n < g_variant_n_children (ui->faces); ++n) { g_variant_get_child (ui->faces, 0, "(iiii)", &x, &y, &w, &h); cairo_rectangle (cr, x, y, w, h); } GST_SWITCH_UI_UNLOCK_FACES (ui); cairo_stroke (cr); cairo_set_source_rgba (cr, 0.9, 0.1, 0.1, 0.8); GST_SWITCH_UI_LOCK_TRACKING (ui); for (n = 0; ui->tracking && n < g_variant_n_children (ui->tracking); ++n) { g_variant_get_child (ui->tracking, 0, "(iiii)", &x, &y, &w, &h); cairo_rectangle (cr, x, y, w, h); } GST_SWITCH_UI_UNLOCK_TRACKING (ui); cairo_stroke (cr); }
void rpmostree_print_signatures (GVariant *variant, const gchar *sep, gboolean verbose) { const guint n_sigs = g_variant_n_children (variant); g_autoptr(GString) sigs_buffer = g_string_sized_new (256); for (guint i = 0; i < n_sigs; i++) { g_autoptr(GVariant) v = NULL; if (i != 0) g_string_append_c (sigs_buffer, '\n'); g_variant_get_child (variant, i, "v", &v); if (verbose) ostree_gpg_verify_result_describe_variant (v, sigs_buffer, sep, OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT); else { gboolean valid; g_variant_get_child (v, OSTREE_GPG_SIGNATURE_ATTR_VALID, "b", &valid); const char *fingerprint; g_variant_get_child (v, OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT, "&s", &fingerprint); if (i != 0) g_string_append (sigs_buffer, sep); g_string_append_printf (sigs_buffer, "%s signature by %s\n", valid ? "Valid" : "Invalid", fingerprint); } } g_print ("%s", sigs_buffer->str); }
static GtkWidget * deserialize_choice (GVariant *choice, FileDialogHandle *handle) { GtkWidget *widget; const char *choice_id; const char *label; const char *selected; GVariant *choices; int i; g_variant_get (choice, "(&s&s@a(ss)&s)", &choice_id, &label, &choices, &selected); if (g_variant_n_children (choices) > 0) { GtkWidget *box; GtkWidget *combo; box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (box), gtk_label_new (label)); combo = gtk_combo_box_text_new (); g_object_set_data_full (G_OBJECT (combo), "choice-id", g_strdup (choice_id), g_free); gtk_container_add (GTK_CONTAINER (box), combo); for (i = 0; i < g_variant_n_children (choices); i++) { const char *id; const char *text; g_variant_get_child (choices, i, "(&s&s)", &id, &text); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), id, text); } if (strcmp (selected, "") == 0) g_variant_get_child (choices, 0, "(&s&s)", &selected, NULL); g_signal_connect (combo, "changed", G_CALLBACK (choice_changed), handle); gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), selected); widget = box; } else { GtkWidget *check; check = gtk_check_button_new_with_label (label); g_object_set_data_full (G_OBJECT (check), "choice-id", g_strdup (choice_id), g_free); g_signal_connect (check, "toggled", G_CALLBACK (choice_toggled), handle); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), g_strcmp0 (selected, "true") == 0); widget = check; } gtk_widget_show_all (widget); return widget; }
static void on_manager_signal (GDBusProxy *proxy, char *sender_name, char *signal_name, GVariant *parameters, gpointer user_data) { GUPnPNetworkManager *manager; manager = GUPNP_NETWORK_MANAGER (user_data); if (g_strcmp0 (signal_name, "DeviceAdded") == 0) { char *device_path = NULL; g_variant_get_child (parameters, 0, "o", &device_path); if (G_UNLIKELY (device_path == NULL)) return; g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, DBUS_SERVICE_NM, device_path, DEVICE_INTERFACE, manager->priv->cancellable, device_proxy_new_cb, manager); g_free (device_path); } else if (g_strcmp0 (signal_name, "DeviceRemoved") == 0) { GList *device_node; NMDevice *nm_device; GUPnPNetworkManagerPrivate *priv; char *device_path = NULL; g_variant_get_child (parameters, 0, "o", &device_path); if (G_UNLIKELY (device_path == NULL)) return; priv = manager->priv; device_node = g_list_find_custom ( priv->nm_devices, device_path, (GCompareFunc) compare_device_path); if (G_UNLIKELY (device_node == NULL)) { g_free (device_path); return; } nm_device = (NMDevice *) device_node->data; priv->nm_devices = g_list_remove (priv->nm_devices, nm_device); nm_device_free (nm_device); g_free (device_path); } }
static gboolean scan_commit_object (OtPullData *pull_data, const char *checksum, guint recursion_depth, GCancellable *cancellable, GError **error) { gboolean ret = FALSE; gs_unref_variant GVariant *commit = NULL; gs_unref_variant GVariant *tree_contents_csum = NULL; gs_unref_variant GVariant *tree_meta_csum = NULL; GVariantIter *iter = NULL; if (recursion_depth > OSTREE_MAX_RECURSION) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Exceeded maximum recursion"); goto out; } #ifdef HAVE_GPGME if (pull_data->gpg_verify) { if (!ostree_repo_verify_commit (pull_data->repo, checksum, NULL, NULL, cancellable, error)) goto out; } #endif if (!ostree_repo_load_variant (pull_data->repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, &commit, error)) goto out; /* PARSE OSTREE_SERIALIZED_COMMIT_VARIANT */ g_variant_get_child (commit, 6, "@ay", &tree_contents_csum); g_variant_get_child (commit, 7, "@ay", &tree_meta_csum); if (!scan_one_metadata_object (pull_data, ostree_checksum_bytes_peek (tree_contents_csum), OSTREE_OBJECT_TYPE_DIR_TREE, recursion_depth + 1, cancellable, error)) goto out; if (!scan_one_metadata_object (pull_data, ostree_checksum_bytes_peek (tree_meta_csum), OSTREE_OBJECT_TYPE_DIR_META, recursion_depth + 1, cancellable, error)) goto out; ret = TRUE; out: if (iter) g_variant_iter_free (iter); return ret; }
static void run_operation_from_params (CcWacomPanel *self, GVariant *parameters) { GVariant *v; CcWacomPage *page; const gchar *operation = NULL; const gchar *device_name = NULL; gint n_params; n_params = g_variant_n_children (parameters); g_variant_get_child (parameters, n_params - 1, "v", &v); device_name = g_variant_get_string (v, NULL); if (!g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)) { g_warning ("Wrong type for the second argument GVariant, expected 's' but got '%s'", g_variant_get_type_string (v)); g_variant_unref (v); return; } g_variant_unref (v); switch (n_params) { case 3: page = set_device_page (self, device_name); if (page == NULL) return; g_variant_get_child (parameters, 1, "v", &v); if (!g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)) { g_warning ("Wrong type for the operation name argument. A string is expected."); g_variant_unref (v); break; } operation = g_variant_get_string (v, NULL); if (g_strcmp0 (operation, "run-calibration") == 0) { if (cc_wacom_page_can_calibrate (page)) cc_wacom_page_calibrate (page); else g_warning ("The device %s cannot be calibrated.", device_name); } else { g_warning ("Ignoring unrecognized operation '%s'", operation); } g_variant_unref (v); case 2: set_device_page (self, device_name); break; case 1: g_assert_not_reached (); default: g_warning ("Unexpected number of parameters found: %d. Request ignored.", n_params); } }
SecretValue * _secret_session_decode_secret (SecretSession *session, GVariant *encoded) { SecretValue *result; gconstpointer param; gconstpointer value; gchar *session_path; gchar *content_type; gsize n_param; gsize n_value; GVariant *vparam; GVariant *vvalue; g_return_val_if_fail (session != NULL, NULL); g_return_val_if_fail (encoded != NULL, NULL); /* Parsing (oayays) */ g_variant_get_child (encoded, 0, "o", &session_path); if (session_path == NULL || !g_str_equal (session_path, session->path)) { g_message ("received a secret encoded with wrong session: %s != %s", session_path, session->path); g_free (session_path); return NULL; } vparam = g_variant_get_child_value (encoded, 1); param = g_variant_get_fixed_array (vparam, &n_param, sizeof (guchar)); vvalue = g_variant_get_child_value (encoded, 2); value = g_variant_get_fixed_array (vvalue, &n_value, sizeof (guchar)); g_variant_get_child (encoded, 3, "s", &content_type); #ifdef WITH_GCRYPT if (session->key != NULL) result = service_decode_aes_secret (session, param, n_param, value, n_value, content_type); else #endif result = service_decode_plain_secret (session, param, n_param, value, n_value, content_type); g_variant_unref (vparam); g_variant_unref (vvalue); g_free (content_type); g_free (session_path); return result; }
void InterfaceManagerImpl::handleNetManagerSignal(const std::string &signalName, GVariant *params) { unique_lock lock(mMutex); try { if(signalName == NM_SIGNAL_DEVICE_ADDED || signalName == NM_SIGNAL_DEVICE_REMOVED ) { const char *devPath; g_variant_get_child (params, 0, "&o", &devPath); if(signalName == NM_SIGNAL_DEVICE_ADDED) { InterfaceInfo info = getDeviceInfo(devPath); mInterfaces.insert(InterfaceInfoPair(devPath, info)); interfaceListUpdateSignal(info, true); } else if(signalName == NM_SIGNAL_DEVICE_REMOVED) { auto info = mInterfaces.find(devPath); if(info != mInterfaces.end()) { InterfaceInfo devInfo = info->second; mInterfaces.erase(devPath); interfaceListUpdateSignal(devInfo, false); } } } } catch(const std::exception& e){ updateFailedSignal(); } }
static void on_client_signal (GDBusProxy *client, gchar *sender_name, gchar *signal_name, GVariant *parameters, gpointer user_data) { char *location_path; if (g_strcmp0 (signal_name, "LocationUpdated") != 0) return; g_assert (g_variant_n_children (parameters) > 1); g_variant_get_child (parameters, 1, "&o", &location_path); g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.GeoClue2", location_path, "org.freedesktop.GeoClue2.Location", NULL, on_location_proxy_ready, user_data); g_object_unref (client); }
static void on_get_client_ready (GObject *source_object, GAsyncResult *res, gpointer user_data) { GDBusProxy *manager = G_DBUS_PROXY (source_object); GVariant *results; const char *client_path; GError *error = NULL; results = g_dbus_proxy_call_finish (manager, res, &error); if (results == NULL) { g_critical ("Failed to connect to GeoClue2 service: %s", error->message); exit (-2); } g_assert (g_variant_n_children (results) > 0); g_variant_get_child (results, 0, "&o", &client_path); g_print ("Client object: %s\n", client_path); g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.GeoClue2", client_path, "org.freedesktop.GeoClue2.Client", NULL, on_client_proxy_ready, manager); g_variant_unref (results); }
static void on_device_signal (GDBusProxy *proxy, char *sender_name, char *signal_name, GVariant *parameters, gpointer user_data) { NMDevice *nm_device; unsigned int new_state; if (g_strcmp0 (signal_name, "StateChanged") != 0) return; nm_device = (NMDevice *) user_data; g_variant_get_child (parameters, 0, "u", &new_state); if (new_state == NM_OLD_DEVICE_STATE_ACTIVATED || new_state == NM_DEVICE_STATE_ACTIVATED) on_device_activated (nm_device); else if (nm_device->context != NULL) { /* For all other states we just destroy the context */ g_signal_emit_by_name (nm_device->manager, "context-unavailable", nm_device->context); g_object_unref (nm_device->context); nm_device->context = NULL; if (nm_device->ap_proxy != NULL) { g_object_unref (nm_device->ap_proxy); nm_device->ap_proxy = NULL; } } }
/** * @brief * @param ui The GstSwitchUI instance. * @memberof GstSwitchUI */ static void gst_switch_ui_prepare_videos (GstSwitchUI * ui) { GVariant *preview_ports; gsize n, num_previews = 0; gint port; port = gst_switch_client_get_compose_port (GST_SWITCH_CLIENT (ui)); gst_switch_ui_set_compose_port (ui, port); port = gst_switch_client_get_audio_port (GST_SWITCH_CLIENT (ui)); gst_switch_ui_set_audio_port (ui, port); port = gst_switch_client_get_encode_port (GST_SWITCH_CLIENT (ui)); INFO ("Encoded output port: %d", port); preview_ports = gst_switch_client_get_preview_ports (GST_SWITCH_CLIENT (ui)); if (preview_ports) { GVariant *ports = NULL; GError *error = NULL; gchar *s = NULL; gint serve, type; g_variant_get (preview_ports, "(&s)", &s); ports = g_variant_parse (G_VARIANT_TYPE ("a(iii)"), s, NULL, NULL, &error); num_previews = g_variant_n_children (ports); for (n = 0; n < num_previews; ++n) { g_variant_get_child (ports, n, "(iii)", &port, &serve, &type); gst_switch_ui_add_preview_port (ui, port, serve, type); //INFO ("preview: %d, %d, %d", port, serve, type); } } }
static GomDlnaPhotoItem * photo_item_new (GVariant *var) { GVariant *tmp; GomDlnaPhotoItem *photo; const gchar *str; photo = g_slice_new0 (GomDlnaPhotoItem); g_variant_lookup (var, "DisplayName", "&s", &str); photo->name = gom_filename_strip_extension (str); g_variant_lookup (var, "MIMEType", "&s", &str); photo->mimetype = g_strdup (str); g_variant_lookup (var, "Path", "&o", &str); photo->path = g_strdup (str); g_variant_lookup (var, "Type", "s", &str); photo->type = g_strdup (str); if (g_str_equal (photo->type, "container")) { photo->url = NULL; goto out; } g_variant_lookup (var, "URLs", "@as", &tmp); g_variant_get_child (tmp, 0, "&s", &str); photo->url = g_strdup (str); g_variant_unref (tmp); out: return photo; }
void gst_switch_server_mark_face (GstSwitchServer * srv, GVariant * faces, gboolean tracking) { const int size = g_variant_n_children (faces); const double cw = srv->composite->a_width; const double ch = srv->composite->a_height; double rx = 1.0, ry = 1.0, dx, dy, sw = GST_SWITCH_FACEDETECT_FRAME_WIDTH, sh = GST_SWITCH_FACEDETECT_FRAME_HEIGHT; GVariantBuilder *vb = g_variant_builder_new (G_VARIANT_TYPE_ARRAY); int x, y, w, h, n; rx = sw / cw; ry = sh / ch; dx = rx * ((double) srv->composite->a_x); dy = ry * ((double) srv->composite->a_y); for (n = 0; n < size; ++n) { g_variant_get_child (faces, n, "(iiii)", &x, &y, &w, &h); x = rx * ((double) x) + 0.5 + dx; y = ry * ((double) y) + 0.5 + dy; w = rx * ((double) w) + 0.5; h = ry * ((double) h) + 0.5; g_variant_builder_add (vb, "(iiii)", x, y, w, h); } if (tracking) { gst_switch_controller_show_track_marker (srv->controller, g_variant_builder_end (vb)); } else { gst_switch_controller_show_face_marker (srv->controller, g_variant_builder_end (vb)); } g_variant_builder_unref (vb); }
static void cc_sound_panel_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { CcSoundPanel *self = CC_SOUND_PANEL (object); switch (property_id) { case PROP_PARAMETERS: { GVariant *parameters; parameters = g_value_get_variant (value); if (parameters && g_variant_n_children (parameters) > 1) { GVariant *v; /* Skip the first child, we don't expect any flag */ g_variant_get_child (parameters, 1, "v", &v); gvc_mixer_dialog_set_page (self->dialog, g_variant_get_string (v, NULL)); g_variant_unref (v); } break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void on_get_user_id_ready (GObject *source_object, GAsyncResult *res, gpointer user_data) { GTask *task = G_TASK (user_data); gpointer *info = g_task_get_source_object (task); GClueClientInfoPrivate *priv = GCLUE_CLIENT_INFO (info)->priv; GError *error = NULL; GVariant *results = NULL; results = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error); if (results == NULL) { g_task_return_error (task, error); g_object_unref (task); return; } g_assert (g_variant_n_children (results) > 0); g_variant_get_child (results, 0, "u", &priv->user_id); g_variant_unref (results); g_dbus_proxy_call (priv->dbus_proxy, "GetConnectionUnixProcessID", g_variant_new ("(s)", priv->bus_name), G_DBUS_CALL_FLAGS_NONE, -1, g_task_get_cancellable (task), on_get_pid_ready, task); }
static ActionInfo * action_info_new_from_iter (GVariantIter *iter) { const gchar *param_str; ActionInfo *info; gboolean enabled; GVariant *state; gchar *name; if (!g_variant_iter_next (iter, "{s(b&g@av)}", &name, &enabled, ¶m_str, &state)) return NULL; info = g_slice_new (ActionInfo); info->name = name; info->enabled = enabled; if (g_variant_n_children (state)) g_variant_get_child (state, 0, "v", &info->state); else info->state = NULL; g_variant_unref (state); if (param_str[0]) info->parameter_type = g_variant_type_copy ((GVariantType *) param_str); else info->parameter_type = NULL; return info; }
static PolkitCheckAuthorizationFlags lookup_invocation_flags (GDBusMethodInvocation *invocation, const GDBusMethodInfo *info) { gboolean auth_no_user_interaction; GVariant *params; GVariant *options; gint i; auth_no_user_interaction = FALSE; /* Find an options, a{sv} */ if (info->in_args) { for (i = 0; info->in_args[i] != NULL; i++) { if (g_str_equal (info->in_args[i]->name, "options") && g_str_equal (info->in_args[i]->signature, "a{sv}")) { params = g_dbus_method_invocation_get_parameters (invocation); g_variant_get_child (params, i, "@a{sv}", &options); g_variant_lookup (options, "auth.no_user_interaction", "b", &auth_no_user_interaction); g_variant_unref (options); } } } return auth_no_user_interaction ? POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE : POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION; }
static gint pkg_diff_variant_compare (gconstpointer a, gconstpointer b, gpointer unused) { const char *pkg_name_a = NULL; const char *pkg_name_b = NULL; g_variant_get_child ((GVariant *) a, 0, "&s", &pkg_name_a); g_variant_get_child ((GVariant *) b, 0, "&s", &pkg_name_b); /* XXX Names should be unique since we're comparing packages * from two different trees... right? */ return g_strcmp0 (pkg_name_a, pkg_name_b); }
static GVariant * translate_kerberos_credential_types (GVariant *creds) { GVariantBuilder bob; g_variant_builder_init (&bob, G_VARIANT_TYPE_STRING_ARRAY); int i; for (i = 0; i < g_variant_n_children (creds); i++) { const gchar *type; const gchar *owner; g_variant_get_child (creds, i, "(&s&s)", &type, &owner); if (strcmp (type, "password") == 0) { if (strcmp (owner, "user") == 0) g_variant_builder_add (&bob, "s", "user"); else if (strcmp (owner, "administrator") == 0) g_variant_builder_add (&bob, "s", "admin"); } else if (strcmp (type, "secret") == 0) { g_variant_builder_add (&bob, "s", "otp"); } else if (strcmp (type, "automatic") == 0) { // XXX - check whether we have the required credentials // before offereing this option g_variant_builder_add (&bob, "s", "none"); } } return g_variant_builder_end (&bob); }
static void update_configuration (GtkTreeModel *model) { GtkTreeIter iter; gchar *type; gchar *id; GVariantBuilder builder; GVariant *old_sources; const gchar *old_current_type; const gchar *old_current_id; guint old_current_index; guint old_n_sources; guint index; old_sources = g_settings_get_value (input_sources_settings, KEY_INPUT_SOURCES); old_current_index = g_settings_get_uint (input_sources_settings, KEY_CURRENT_INPUT_SOURCE); old_n_sources = g_variant_n_children (old_sources); if (old_n_sources > 0 && old_current_index < old_n_sources) { g_variant_get_child (old_sources, old_current_index, "(&s&s)", &old_current_type, &old_current_id); } else { old_current_type = ""; old_current_id = ""; } g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)")); index = 0; gtk_tree_model_get_iter_first (model, &iter); do { gtk_tree_model_get (model, &iter, TYPE_COLUMN, &type, ID_COLUMN, &id, -1); if (index != old_current_index && g_str_equal (type, old_current_type) && g_str_equal (id, old_current_id)) { g_settings_set_uint (input_sources_settings, KEY_CURRENT_INPUT_SOURCE, index); } g_variant_builder_add (&builder, "(ss)", type, id); g_free (type); g_free (id); index += 1; } while (gtk_tree_model_iter_next (model, &iter)); g_settings_set_value (input_sources_settings, KEY_INPUT_SOURCES, g_variant_builder_end (&builder)); g_settings_apply (input_sources_settings); g_variant_unref (old_sources); }
void ibus_g_variant_get_child_string (GVariant *variant, gsize index, char **str) { g_return_if_fail (str != NULL); g_free (*str); g_variant_get_child (variant, index, "s", str); }
static void cc_keyboard_panel_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { CcKeyboardPanel *panel = CC_KEYBOARD_PANEL (object); switch (property_id) { case PROP_PARAMETERS: { GVariant *parameters, *v; const gchar *page, *section; parameters = g_value_get_variant (value); if (!parameters) break; page = section = NULL; switch (g_variant_n_children (parameters)) { case 3: g_variant_get_child (parameters, 2, "v", &v); section = g_variant_get_string (v, NULL); g_variant_unref (v); /* fall-through */ case 2: g_variant_get_child (parameters, 1, "v", &v); page = g_variant_get_string (v, NULL); g_variant_unref (v); cc_keyboard_panel_set_page (panel, page, section); /* fall-through */ case 1: /* No flags expected, fall-through */ case 0: break; default: g_warning ("Unexpected parameters found, ignore request"); } break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void infinoted_plugin_dbus_check_acl(InfinotedPluginDbus* plugin, InfinotedPluginDbusInvocation* invocation, InfBrowser* browser, const InfBrowserIter* iter) { const gchar* account; GVariant* mask_variant; InfAclMask mask; InfAclMask out; GError* error; g_variant_get_child(invocation->parameters, 1, "&s", &account); g_variant_get_child(invocation->parameters, 2, "@as", &mask_variant); error = NULL; infinoted_plugin_dbus_mask_from_variant(&mask, mask_variant, &error); g_variant_unref(mask_variant); if(error != NULL) { g_dbus_method_invocation_return_gerror(invocation->invocation, error); g_error_free(error); } else { inf_browser_check_acl( browser, iter, inf_acl_account_id_from_string(account), &mask, &out ); g_dbus_method_invocation_return_value( invocation->invocation, g_variant_new( "(@a{sb})", infinoted_plugin_dbus_perms_to_variant(&mask, &out) ) ); } infinoted_plugin_dbus_invocation_free(plugin, invocation); }
static void response_cb (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) { GtkFileChooserNative *self = user_data; FilechooserPortalData *data = self->mode_data; guint32 portal_response; int gtk_response; const char **uris; int i; GVariant *response_data; g_autoptr (GVariant) choices = NULL; g_variant_get (parameters, "(u@a{sv})", &portal_response, &response_data); g_variant_lookup (response_data, "uris", "^a&s", &uris); choices = g_variant_lookup_value (response_data, "choices", G_VARIANT_TYPE ("a(ss)")); if (choices) for (i = 0; i < g_variant_n_children (choices); i++) { const char *id; const char *selected; g_variant_get_child (choices, i, "(&s&s)", &id, &selected); gtk_file_chooser_set_choice (GTK_FILE_CHOOSER (self), id, selected); } g_slist_free_full (self->custom_files, g_object_unref); self->custom_files = NULL; for (i = 0; uris[i]; i++) self->custom_files = g_slist_prepend (self->custom_files, g_file_new_for_uri (uris[i])); switch (portal_response) { case 0: gtk_response = GTK_RESPONSE_OK; break; case 1: gtk_response = GTK_RESPONSE_CANCEL; break; case 2: default: gtk_response = GTK_RESPONSE_DELETE_EVENT; break; } filechooser_portal_data_free (data); self->mode_data = NULL; _gtk_native_dialog_emit_response (GTK_NATIVE_DIALOG (self), gtk_response); }
static gboolean deserialize_secret (const char *secret, char **token, char **token_secret) { GVariant *variant; variant = g_variant_parse (NULL, secret, NULL, NULL, NULL); if (variant == NULL) return FALSE; if (token != NULL) g_variant_get_child (variant, 0, "ms", token, NULL); if (token_secret != NULL) g_variant_get_child (variant, 1, "ms", token_secret, NULL); g_variant_unref (variant); return TRUE; }
static void infinoted_plugin_dbus_query_acl(InfinotedPluginDbus* plugin, InfinotedPluginDbusInvocation* invocation, InfBrowser* browser, const InfBrowserIter* iter) { const InfAclSheetSet* sheet_set; const InfAclSheet* sheet; const gchar* account; InfAclAccountId id; GVariantBuilder builder; /* TODO: Actually query the ACL if not available */ sheet_set = inf_browser_get_acl(browser, iter); g_variant_get_child(invocation->parameters, 1, "&s", &account); if(*account == '\0') { g_dbus_method_invocation_return_value( invocation->invocation, g_variant_new( "(@a{sa{sb}})", infinoted_builder_dbus_sheet_set_to_variant(sheet_set) ) ); } else { id = inf_acl_account_id_from_string(account); if(sheet_set != NULL) sheet = inf_acl_sheet_set_find_const_sheet(sheet_set, id); else sheet = NULL; g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sa{sb}}")); if(sheet != NULL) { g_variant_builder_add( &builder, "{s@a{sb}}", account, infinoted_plugin_dbus_perms_to_variant(&sheet->mask, &sheet->perms) ); } g_dbus_method_invocation_return_value( invocation->invocation, g_variant_new("(@a{sa{sb}})", g_variant_builder_end(&builder)) ); } infinoted_plugin_dbus_invocation_free(plugin, invocation); }
static void open_file_msg_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { FilechooserPortalData *data = user_data; GtkFileChooserNative *self = data->self; GDBusMessage *reply; GError *error = NULL; reply = g_dbus_connection_send_message_with_reply_finish (data->connection, res, &error); if (reply && g_dbus_message_to_gerror (reply, &error)) g_clear_object (&reply); if (reply == NULL) { if (!data->hidden) _gtk_native_dialog_emit_response (GTK_NATIVE_DIALOG (self), GTK_RESPONSE_DELETE_EVENT); g_warning ("Can't open portal file chooser: %s", error->message); g_error_free (error); filechooser_portal_data_free (data); self->mode_data = NULL; return; } g_variant_get_child (g_dbus_message_get_body (reply), 0, "o", &data->portal_handle); if (data->hidden) { /* The dialog was hidden before we got the handle, close it now */ send_close (data); filechooser_portal_data_free (data); self->mode_data = NULL; } else { data->portal_response_signal_id = g_dbus_connection_signal_subscribe (data->connection, "org.freedesktop.portal.Desktop", "org.freedesktop.portal.Request", "Response", data->portal_handle, NULL, G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE, response_cb, self, NULL); } g_object_unref (reply); }
static void modem_signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name, GVariant *parameters, gpointer user_data) { UrfDeviceOfono *modem = URF_DEVICE_OFONO (user_data); UrfDeviceOfonoPrivate *priv = URF_DEVICE_OFONO_GET_PRIVATE (modem); if (g_strcmp0 (signal_name, "PropertyChanged") == 0) { gchar *prop_name; GVariant *prop_value = NULL; g_debug ("properties changed for %s: %s", priv->object_path, g_variant_print (parameters, TRUE)); g_variant_get_child (parameters, 0, "s", &prop_name); g_variant_get_child (parameters, 1, "v", &prop_value); if (prop_value) g_hash_table_replace (priv->properties, g_strdup (prop_name), g_variant_ref (prop_value)); if (g_strcmp0 ("Powered", prop_name) == 0) { gboolean powered = FALSE; powered = g_variant_get_boolean (prop_value); if (powered) set_soft (URF_DEVICE (modem), priv->soft); } g_free (prop_name); g_variant_unref (prop_value); } }
static gboolean repo_prune_internal (OstreeRepo *self, GHashTable *objects, OstreeRepoPruneOptions *options, gint *out_objects_total, gint *out_objects_pruned, guint64 *out_pruned_object_size_total, GCancellable *cancellable, GError **error) { GHashTableIter hash_iter; gpointer key, value; OtPruneData data = { 0, }; data.repo = self; /* We unref this when we're done */ g_autoptr(GHashTable) reachable_owned = g_hash_table_ref (options->reachable); data.reachable = reachable_owned; g_hash_table_iter_init (&hash_iter, objects); while (g_hash_table_iter_next (&hash_iter, &key, &value)) { GVariant *serialized_key = key; GVariant *objdata = value; const char *checksum; OstreeObjectType objtype; gboolean is_loose; ostree_object_name_deserialize (serialized_key, &checksum, &objtype); g_variant_get_child (objdata, 0, "b", &is_loose); if (!is_loose) continue; if (!maybe_prune_loose_object (&data, options->flags, checksum, objtype, cancellable, error)) return FALSE; } if (!ostree_repo_prune_static_deltas (self, NULL, cancellable, error)) return FALSE; if (!_ostree_repo_prune_tmp (self, cancellable, error)) return FALSE; *out_objects_total = (data.n_reachable_meta + data.n_unreachable_meta + data.n_reachable_content + data.n_unreachable_content); *out_objects_pruned = (data.n_unreachable_meta + data.n_unreachable_content); *out_pruned_object_size_total = data.freed_bytes; return TRUE; }