unsigned char bluez_characteristic_extract_value(GVariant* variant) { GVariant* var_array = g_variant_get_child_value(variant, 0); for(unsigned int i = 0; i < g_variant_n_children(var_array); i++) { GVariant* var_child = g_variant_get_child_value(var_array, i); if(g_variant_n_children(var_child) == 2) { GVariant* var_id = g_variant_get_child_value(var_child, 0); if(g_variant_type_equal(g_variant_get_type(var_id), G_VARIANT_TYPE_STRING) && g_strcmp0(g_variant_get_string(var_id, NULL), "Value") == 0) { GVariant* inner_var = g_variant_get_child_value(var_child, 1); if( g_variant_type_equal(g_variant_get_type(inner_var), G_VARIANT_TYPE_VARIANT) ) { GVariant* var_value = g_variant_get_variant(inner_var); if( g_variant_type_equal(g_variant_get_type(var_value), G_VARIANT_TYPE_BYTESTRING) ) { GVariant* var_byte = g_variant_get_child_value(var_value, 0); return g_variant_get_byte(var_byte); } } } } g_variant_unref(var_child); } return 0; }
static void services_changed(GVariant *params) { connman_service_t *prev = NULL, *cs; GVariant *del = g_variant_get_child_value(params, 1); for(int i = 0, n = g_variant_n_children(del); i < n; i++) { GVariant *v = g_variant_get_child_value(del, i); if(g_variant_type_equal(g_variant_get_type(v), G_VARIANT_TYPE_OBJECT_PATH)) { const char *name = g_variant_get_string(v, NULL); TRACE(TRACE_DEBUG, "CONNMAN", "Deleted network %s", name); if((cs = connman_service_find(name)) != NULL) connman_service_destroy(cs); } } GVariant *add = g_variant_get_child_value(params, 0); for(int i = 0, n = g_variant_n_children(add); i < n; i++) { GVariant *v = g_variant_get_child_value(add, i); const char *id = g_variant_get_string(g_variant_get_child_value(v, 0), NULL); cs = update_service(g_variant_get_child_value(v, 1), id, prev); if(cs != NULL) prev = cs; } }
gboolean connman_manager_update_technologies (ConnmanManager *manager) { GVariant *props = connman_manager_get_properties(manager); gsize i; for (i = 0; i < g_variant_n_children(props); i++) { GVariant *prop = g_variant_get_child_value(props, i); GVariant *key_v = g_variant_get_child_value(prop, 0); const gchar *key = g_variant_get_string(key_v, NULL); if (g_str_equal(key, "Technologies")) { GVariant *v = g_variant_get_child_value(prop, 1); GVariant *array = g_variant_get_variant(v); gsize j; for (j = 0; j < g_variant_n_children(array); j++) { GVariant *item = g_variant_get_child_value(array, j); const gchar *path = g_variant_get_string(item, NULL); ConnmanTechnology *technology; technology = connman_technology_new(manager->bus_type, path); manager->technologies = g_slist_append(manager->technologies, technology); } } } return TRUE; }
static void on_manager_svc_changed_signal (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) { GUPnPConnmanManager *manager; GVariant *add_array; GVariant *remove_array; manager = GUPNP_CONNMAN_MANAGER (user_data); add_array = g_variant_get_child_value (parameters, 0); remove_array = g_variant_get_child_value (parameters, 1); if ((add_array != NULL) && (g_variant_n_children (add_array) > 0)) services_array_add (manager, add_array); if ((remove_array != NULL) && (g_variant_n_children (remove_array) > 0)) services_array_remove (manager, remove_array); g_variant_unref (add_array); g_variant_unref (remove_array); }
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); }
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 test_getservers_slmock_none (void) { DbusTestService * service = dbus_test_service_new(NULL); /* RLS */ DbusTestProcess * rls = dbus_test_process_new(REMOTE_LOGON_SERVICE); dbus_test_process_append_param(rls, "--config-file=" SLMOCK_CONFIG_FILE); dbus_test_service_add_task(service, DBUS_TEST_TASK(rls)); /* Dummy */ DbusTestTask * dummy = dbus_test_task_new(); dbus_test_task_set_wait_for(dummy, "org.ArcticaProject.RemoteLogon"); dbus_test_service_add_task(service, dummy); /* Get RLS up and running and us on that bus */ dbus_test_service_start_tasks(service); GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); g_dbus_connection_set_exit_on_close(session, FALSE); GVariant * retval = g_dbus_connection_call_sync(session, "org.ArcticaProject.RemoteLogon", "/org/ArcticaProject/RemoteLogon", "org.ArcticaProject.RemoteLogon", "GetServersForLogin", g_variant_new("(sssb)", "https://slmock.com/", "Baduser", "Badpass", TRUE), /* params */ G_VARIANT_TYPE("(bsa(sssba(sbva{sv})a(si)))"), /* ret type */ G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); g_assert(retval != NULL); g_assert(g_variant_n_children(retval) == 3); GVariant * loggedin = g_variant_get_child_value(retval, 0); g_assert(!g_variant_get_boolean(loggedin)); g_variant_unref(loggedin); loggedin = NULL; GVariant * array = g_variant_get_child_value(retval, 2); g_assert(g_variant_n_children(array) == 0); g_variant_unref(array); g_variant_unref(retval); g_object_unref(session); g_object_unref(rls); g_object_unref(service); return; }
static gboolean slmock_check_login(GDBusConnection * session, slmock_table_t * slmockdata, gboolean clear_cache) { if (clear_cache) { gchar *username_sha = g_compute_checksum_for_string (G_CHECKSUM_SHA256, slmockdata->username, -1); gchar *file_path = g_build_path ("/", g_get_user_cache_dir(), "remote-logon-service", "cache", username_sha, NULL); unlink (file_path); g_free (username_sha); g_free (file_path); } GVariant * retval = g_dbus_connection_call_sync(session, "org.ArcticaProject.RemoteLogon", "/org/ArcticaProject/RemoteLogon", "org.ArcticaProject.RemoteLogon", "GetServersForLogin", g_variant_new("(sssb)", "https://slmock.com/", slmockdata->username, slmockdata->password, TRUE), /* params */ G_VARIANT_TYPE("(bsa(sssba(sbva{sv})a(si)))"), /* ret type */ G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); g_assert(retval != NULL); g_assert(g_variant_n_children(retval) == 3); GVariant * loggedin = g_variant_get_child_value(retval, 0); g_assert(g_variant_get_boolean(loggedin)); g_variant_unref(loggedin); loggedin = NULL; GVariant * data = g_variant_get_child_value(retval, 1); g_assert(g_strcmp0(g_variant_get_string(data, NULL), "network") == 0); g_variant_unref(data); data = NULL; GVariant * array = g_variant_get_child_value(retval, 2); int i; // Check all servers should be in the result are in the result for (i = 0; slmockdata->servers[i].name != NULL; i++) { g_assert(find_server(array, &slmockdata->servers[i])); } // Check there is no more servers in the result than we expected g_assert(i == g_variant_n_children(array)); g_variant_unref(array); g_variant_unref(retval); return TRUE; }
static const gchar *lookup(GVariant *dictionary, const gchar *lookup_key, const gchar *default_value) { GVariantIter dictionary_iter; g_variant_iter_init(&dictionary_iter, dictionary); const char *key = NULL; GVariant *value = NULL; while (g_variant_iter_loop(&dictionary_iter, "{s@v}", &key, &value)) { if(strcmp(key, lookup_key) != 0) continue; GVariant *unboxed = g_variant_get_variant(value); if(strcmp(g_variant_get_type_string(unboxed), "s") == 0) { return g_variant_get_string(unboxed, NULL); } else if(strcmp(g_variant_get_type_string(unboxed), "ay") != 0) { return g_variant_print(unboxed, FALSE); } else if(g_variant_n_children(unboxed) < 256) { // skip preview gchar *buffer = (gchar *)malloc(256+1); int i=0; guchar c; GVariantIter char_iter; g_variant_iter_init(&char_iter, unboxed); while (g_variant_iter_loop(&char_iter, "y", &c)) { buffer[i] = c; ++i; } buffer[i] = 0; return buffer; } } return default_value; }
static gboolean do_read_run (GLnxDirFdIterator *dfd_iter, guint *out_n_read, GError **error) { guint nattrs = 0; while (TRUE) { struct dirent *dent; if (!glnx_dirfd_iterator_next_dent (dfd_iter, &dent, NULL, error)) return FALSE; if (!dent) break; glnx_autofd int fd = -1; if (!glnx_openat_rdonly (dfd_iter->fd, dent->d_name, FALSE, &fd, error)) return FALSE; g_autoptr(GVariant) current_xattrs = NULL; if (!glnx_fd_get_all_xattrs (fd, ¤t_xattrs, NULL, error)) return FALSE; /* We don't actually care about the values, just use the variable * to avoid compiler warnings. */ nattrs += g_variant_n_children (current_xattrs); } *out_n_read = nattrs; return TRUE; }
void cb_cpu_color_changed (GSMColorButton *cp, gpointer data) { guint cpu_i = GPOINTER_TO_UINT (data); GSettings *settings = g_settings_new (GSM_GSETTINGS_SCHEMA); /* Get current values */ GVariant *cpu_colors_var = g_settings_get_value(settings, "cpu-colors"); gsize children_n = g_variant_n_children(cpu_colors_var); /* Create builder to contruct new setting with updated value for cpu i */ GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); for (guint i = 0; i < children_n; i++) { if(cpu_i == i) { gchar color[24]; GdkColor button_color; gsm_color_button_get_color(cp, &button_color); g_snprintf(color, sizeof(color), "#%04x%04x%04x", button_color.red, button_color.green, button_color.blue); g_variant_builder_add(&builder, "(us)", i, color); } else { g_variant_builder_add_value(&builder, g_variant_get_child_value(cpu_colors_var, i)); } } /* Just set the value and let the changed::cpu-colors signal callback do the rest. */ g_settings_set_value(settings, "cpu-colors", g_variant_builder_end(&builder)); }
static void bluez_handle_disconnect(GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) { // check if parameter is valid and is the parameter we were looking for if( !(g_variant_type_equal(g_variant_get_type(parameters), "(sv)") && g_variant_n_children(parameters) == 2) ) return; GVariant* name = g_variant_get_child_value(parameters, 0); GVariant* value = g_variant_get_variant(g_variant_get_child_value(parameters, 1)); if( !(g_strcmp0(g_variant_get_string(name, NULL), "Connected") == 0 && g_variant_type_equal(g_variant_get_type(value), G_VARIANT_TYPE_BOOLEAN) ) ) return; gboolean connected = g_variant_get_boolean(value); g_printf("Connected: %d\n", connected); if(!connected) { gchar* device_path = (gchar*)user_data; gchar* service_path = g_strconcat(device_path, "/service0007", NULL); bluez_unregister_watcher(connection, service_path); bluez_register_watcher(connection, service_path); } }
static void cc_wacom_panel_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { CcWacomPanel *self; self = CC_WACOM_PANEL (object); switch (property_id) { case PROP_PARAMETERS: { GVariant *parameters; parameters = g_value_get_variant (value); if (parameters == NULL || g_variant_n_children (parameters) <= 1) return; run_operation_from_params (self, parameters); break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static gboolean check_variant_array_domain(GVariant *values, GVariant *domain) { gsize iter; gsize array_len; gboolean correct; if (!domain) { return TRUE; } if (!g_variant_is_of_type(domain, G_VARIANT_TYPE_ARRAY)) { return FALSE; } array_len = g_variant_n_children(values); correct = TRUE; for (iter = 0; iter < array_len && correct; ++iter) { GVariant *child = g_variant_get_child_value(values, iter); correct = check_single_value_domain(child, domain); g_variant_unref (child); } return correct; }
static void mms_ofono_manager_set_modems( MMSOfonoManager* ofono, GVariant* modems) { GVariantIter iter; GVariant* child; MMS_DEBUG("%u modem(s) found", (guint)g_variant_n_children(modems)); g_hash_table_remove_all(ofono->modems); for (g_variant_iter_init(&iter, modems); (child = g_variant_iter_next_value(&iter)) != NULL; g_variant_unref(child)) { MMSOfonoModem* modem; const char* path = NULL; GVariant* properties = NULL; g_variant_get(child, "(&o@a{sv})", &path, &properties); MMS_ASSERT(path); MMS_ASSERT(properties); modem = mms_ofono_modem_new(ofono->bus, path, properties); if (modem) g_hash_table_replace(ofono->modems, modem->path, modem); g_variant_unref(properties); } }
/** * @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); } } }
void cb_cpu_color_changed (GsmColorButton *cp, gpointer data) { guint cpu_i = GPOINTER_TO_UINT (data); auto settings = Gio::Settings::create (GSM_GSETTINGS_SCHEMA); /* Get current values */ GVariant *cpu_colors_var = g_settings_get_value (settings->gobj(), GSM_SETTING_CPU_COLORS); gsize children_n = g_variant_n_children(cpu_colors_var); /* Create builder to contruct new setting with updated value for cpu i */ GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); for (guint i = 0; i < children_n; i++) { if(cpu_i == i) { gchar *color; GdkRGBA button_color; gsm_color_button_get_color(cp, &button_color); color = gdk_rgba_to_string (&button_color); g_variant_builder_add(&builder, "(us)", i, color); g_free (color); } else { g_variant_builder_add_value(&builder, g_variant_get_child_value(cpu_colors_var, i)); } } /* Just set the value and let the changed::cpu-colors signal callback do the rest. */ settings->set_value (GSM_SETTING_CPU_COLORS, Glib::wrap (g_variant_builder_end(&builder))); }
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); }
TestPlugin::TestPlugin(AbstractRoutingEngine *re, map<string, string> config) : AbstractSource(re, config) { DebugOut() << "Testing MapPropertyType... " << endl; MapPropertyType<BasicPropertyType<Zone::Type>,BasicPropertyType<Door::Status>> propmap("something"); MapPropertyType<BasicPropertyType<Zone::Type>,BasicPropertyType<Door::Status>> propmaptwo("something"); propmap.append(Zone::RearLeft,Door::Ajar); GVariant *var = propmap.toVariant(); gsize dictsize = g_variant_n_children(var); //DebugOut() << var << endl; propmaptwo.fromVariant(var); g_assert(propmaptwo.toString() == propmap.toString()); DebugOut() << "Testing ListPropertyType... " << endl; VehicleProperty::TripMetersType* tfirst = new VehicleProperty::TripMetersType(); VehicleProperty::TripMetersType* tsecond = new VehicleProperty::TripMetersType(); BasicPropertyType<uint16_t> v1(0); BasicPropertyType<uint16_t> v2(5); BasicPropertyType<uint16_t> v3(10); tfirst->append(&v1); tfirst->append(&v2); tfirst->append(&v3); tsecond->fromVariant(tfirst->toVariant()); g_assert (tfirst->toString() == tsecond->toString()); testBooleanToStringFromString(); g_assert (testCoreUpdateSupported()); DebugOut() << "Exiting..." << endl; exit(-1); }
static void on_properties_changed(GDBusProxy *proxy, GVariant *changed, const char *const *invalidated, gpointer user_data) { struct app *app = user_data; printf("%015.3f --- Properties Changed ---\n", g_timer_elapsed(app->timer, NULL)); if (g_variant_n_children(changed) > 0) { GVariantIter *itr; const char *prop; GVariant *value; printf("Changed Properties:"); g_variant_get(changed, "a{sv}", &itr); while (g_variant_iter_loop(itr, "{&sv}", &prop, &value)) { char *str; str = g_variant_print(value, TRUE); printf(" %s=%s", prop, str); g_free(str); } g_variant_iter_free(itr); printf("\n"); } if (invalidated[0] != NULL) { const char * const *itr; printf("Invalidated Properties:"); for (itr = invalidated; *itr != NULL; itr++) printf(" %s", *itr); printf("\n"); } print_server(proxy); }
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 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); } }
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 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; }
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); }
gboolean _ostree_static_delta_parse_checksum_array (GVariant *array, guint8 **out_checksums_array, guint *out_n_checksums, GError **error) { gsize n = g_variant_n_children (array); guint n_checksums; n_checksums = n / OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN; if (G_UNLIKELY(n == 0 || n > (G_MAXUINT32/OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN) || (n_checksums * OSTREE_STATIC_DELTA_OBJTYPE_CSUM_LEN) != n)) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid checksum array length %" G_GSIZE_FORMAT, n); return FALSE; } *out_checksums_array = (gpointer)g_variant_get_data (array); *out_n_checksums = n_checksums; return TRUE; }
static void on_properties_changed (GDBusProxy *proxy, GVariant *changed_properties, const gchar* const *invalidated_properties, gpointer user_data) { /* * Note that we are guaranteed that changed_properties and * invalidated_properties are never NULL */ if (g_variant_n_children (changed_properties) > 0){ GVariantIter *iter; const gchar *key; GVariant *value; g_printf ("*** Properties Changed:\n"); g_variant_get(changed_properties, "a{sv}", &iter); while (g_variant_iter_loop(iter, "{&sv}", &key, &value)){ gchar *value_str; value_str = g_variant_print (value, TRUE); g_printf(" %s -> %s\n", key, value_str); g_free(value_str); } g_variant_iter_free(iter); } if (g_strv_length((GStrv) invalidated_properties) > 0){ guint n; g_printf ("*** Properties Invalidated:\n"); for (n = 0; invalidated_properties[n] != NULL; n++){ const gchar *key = invalidated_properties[n]; g_printf(" %s\n", key); } } }
static void onPropertiesChanged(GDBusProxy *proxy, GVariant *changed_properties, const gchar* const *invalidated_properties, gpointer pp) { if (g_variant_n_children(changed_properties) > 0) { GVariantIter *iter; gchar *key; GVariant *value; debug(" *** Properties Changed:\n"); g_variant_get(changed_properties, "a{sv}", &iter); while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) { gchar *value_str; value_str = g_variant_print(value, TRUE); g_print(" %s -> %s\n", key, value_str); g_free(value_str); if (strncmp(key, "Metadata",8) == 0) { trackChanged(value); } else if (strcmp(key, "PlaybackStatus") == 0) { playbackChanged(g_variant_dup_string(value, NULL)); } else if (strcmp(key, "LoopStatus") == 0) { loopChanged(g_variant_dup_string(value, NULL)); } else if (strcmp(key, "Shuffle") == 0) { shuffleChanged(g_variant_get_boolean(value)); } else if (strcmp(key, "Position") == 0) { positionChanged(g_variant_get_int64(value)); } else if (strcmp(key, "Volume") == 0) { volumeChanged(g_variant_get_double(value)); } } g_variant_iter_free (iter); } }