本文整理匯總了C++中G_VARIANT_TYPE函數的典型用法代碼示例。如果您正苦於以下問題:C++ G_VARIANT_TYPE函數的具體用法?C++ G_VARIANT_TYPE怎麽用?C++ G_VARIANT_TYPE使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了G_VARIANT_TYPE函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: handle_request_session
static gboolean
handle_request_session (FlatpakSessionHelper *object,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder, "{[email protected]}", "path",
g_variant_new_variant (g_variant_new_string (monitor_dir)));
if (p11_kit_server_socket_path)
g_variant_builder_add (&builder, "{[email protected]}", "pkcs11-socket",
g_variant_new_variant (g_variant_new_string (p11_kit_server_socket_path)));
flatpak_session_helper_complete_request_session (object, invocation,
g_variant_builder_end (&builder));
return TRUE;
}
示例2: iter_get_variant
static gboolean
iter_get_variant (GVariant *variant,
DataType data_type,
gulong attr_type,
GckBuilder *builder)
{
IterGetFunc func = NULL;
gboolean ret;
const GVariantType *sig;
g_assert (variant != NULL);
g_assert (builder != NULL);
switch (data_type) {
case DATA_TYPE_STRING:
func = iter_get_string;
sig = G_VARIANT_TYPE_STRING;
break;
case DATA_TYPE_BOOL:
func = iter_get_bool;
sig = G_VARIANT_TYPE_BOOLEAN;
break;
case DATA_TYPE_TIME:
func = iter_get_time;
sig = G_VARIANT_TYPE_UINT64;
break;
case DATA_TYPE_FIELDS:
func = iter_get_fields;
sig = G_VARIANT_TYPE ("a{ss}");
break;
default:
g_assert (FALSE);
break;
}
ret = g_variant_type_equal (g_variant_get_type (variant), sig);
if (ret == FALSE)
return FALSE;
return (func) (variant, attr_type, builder);
}
示例3: inhibit
static gboolean inhibit (const gchar *app_id,
const gchar *reason,
GsmInhibitorFlag flags)
{
GDBusConnection *bus;
GVariant *ret;
GError *error = NULL;
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (bus == NULL)
{
g_warning ("Failed to connect to session bus: %s", error->message);
g_error_free (error);
return FALSE;
}
ret = g_dbus_connection_call_sync (bus,
"org.gnome.SessionManager",
"/org/gnome/SessionManager",
"org.gnome.SessionManager",
"Inhibit",
g_variant_new ("(susu)",
app_id, 0, reason, flags),
G_VARIANT_TYPE ("(u)"),
0,
G_MAXINT,
NULL,
&error);
if (ret == NULL)
{
g_warning ("Failed to call Inhibit: %s\n", error->message);
g_error_free (error);
return FALSE;
}
g_variant_unref (ret);
return TRUE;
}
示例4: request_open_session_aes
static GVariant *
request_open_session_aes (SecretSession *session)
{
gcry_error_t gcry;
gcry_mpi_t base;
unsigned char *buffer;
size_t n_buffer;
GVariant *argument;
g_assert (session->prime == NULL);
g_assert (session->privat == NULL);
g_assert (session->publi == NULL);
egg_libgcrypt_initialize ();
/* Initialize our local parameters and values */
if (!egg_dh_default_params ("ietf-ike-grp-modp-1024",
&session->prime, &base))
g_return_val_if_reached (NULL);
#if 0
g_printerr ("\n lib prime: ");
gcry_mpi_dump (session->prime);
g_printerr ("\n lib base: ");
gcry_mpi_dump (base);
g_printerr ("\n");
#endif
if (!egg_dh_gen_pair (session->prime, base, 0,
&session->publi, &session->privat))
g_return_val_if_reached (NULL);
gcry_mpi_release (base);
gcry = gcry_mpi_aprint (GCRYMPI_FMT_USG, &buffer, &n_buffer, session->publi);
g_return_val_if_fail (gcry == 0, NULL);
argument = g_variant_new_from_data (G_VARIANT_TYPE ("ay"),
buffer, n_buffer, TRUE,
gcry_free, buffer);
return g_variant_new ("(sv)", ALGORITHMS_AES, argument);
}
示例5: generate_one_delta
static gboolean
generate_one_delta (OstreeRepo *repo,
const char *from,
const char *to,
const char *ref,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GVariantBuilder) parambuilder = NULL;
g_autoptr(GVariant) params = NULL;
parambuilder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
/* Fall back for 1 meg files */
g_variant_builder_add (parambuilder, "{sv}",
"min-fallback-size", g_variant_new_uint32 (1));
params = g_variant_ref_sink (g_variant_builder_end (parambuilder));
if (ref == NULL)
ref = "";
if (from == NULL)
g_print (_("Generating delta: %s (%.10s)\n"), ref, to);
else
g_print (_("Generating delta: %s (%.10s-%.10s)\n"), ref, from, to);
if (!ostree_repo_static_delta_generate (repo, OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR,
from, to, NULL,
params,
cancellable, error))
{
if (from == NULL)
g_prefix_error (error, _("Failed to generate delta %s (%.10s): "),
ref, to);
else
g_prefix_error (error, _("Failed to generate delta %s (%.10s-%.10s): "),
ref, from, to);
return FALSE;
}
return TRUE;
}
示例6: handle_get_environment
static gboolean
handle_get_environment (GkdExportedDaemon *skeleton,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
const gchar **env;
gchar **parts;
GVariantBuilder builder;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
for (env = gkd_util_get_environment (); *env != NULL; env++) {
parts = g_strsplit (*env, "=", 2);
g_variant_builder_add (&builder, "{ss}", parts[0], parts[1]);
g_strfreev (parts);
}
gkd_exported_daemon_complete_get_environment (skeleton, invocation,
g_variant_builder_end (&builder));
return TRUE;
}
示例7: web_extension_form_auth_data_message_received_cb
static void
web_extension_form_auth_data_message_received_cb (WebKitUserContentManager *manager,
WebKitJavascriptResult *message,
EphyEmbedShell *shell)
{
guint request_id;
guint64 page_id;
const char *hostname;
const char *username;
GVariant *variant;
gchar *message_str;
message_str = ephy_embed_utils_get_js_result_as_string (message);
variant = g_variant_parse (G_VARIANT_TYPE ("(utss)"), message_str, NULL, NULL, NULL);
g_free (message_str);
g_variant_get (variant, "(ut&s&s)", &request_id, &page_id, &hostname, &username);
g_signal_emit (shell, signals[FORM_AUTH_DATA_SAVE_REQUESTED], 0,
request_id, page_id, hostname, username);
g_variant_unref (variant);
}
示例8: DLEYNA_LOG_DEBUG
GVariant *dlr_upnp_get_server_ids(dlr_upnp_t *upnp)
{
GVariantBuilder vb;
GHashTableIter iter;
gpointer value;
dlr_device_t *device;
DLEYNA_LOG_DEBUG("Enter");
g_variant_builder_init(&vb, G_VARIANT_TYPE("as"));
g_hash_table_iter_init(&iter, upnp->server_udn_map);
while (g_hash_table_iter_next(&iter, NULL, &value)) {
device = value;
g_variant_builder_add(&vb, "s", device->path);
}
DLEYNA_LOG_DEBUG("Exit");
return g_variant_ref_sink(g_variant_builder_end(&vb));
}
示例9: commit_changes
static void
commit_changes (UIData *ui)
{
GtkTreeModel *model = NULL;
GVariantBuilder b;
GtkTreeIter iter;
gboolean valid;
GVariant *v;
model = gtk_tree_view_get_model (GTK_TREE_VIEW (ui->treeview));
valid = gtk_tree_model_get_iter_first (model, &iter);
g_variant_builder_init (&b, G_VARIANT_TYPE ("as"));
while (valid) {
gchar *keyword, *value;
gchar *key;
gtk_tree_model_get (
model, &iter,
CLUE_KEYWORD_COLUMN, &keyword,
CLUE_VALUE_COLUMN, &value,
-1);
/* Check if the keyword and value are not empty */
if ((keyword) && (value) && (g_utf8_strlen (g_strstrip (keyword), -1) > 0)
&& (g_utf8_strlen (g_strstrip (value), -1) > 0)) {
key = g_strdup_printf ("%s=%s", keyword, value);
g_variant_builder_add (&b, "s", key);
}
g_free (keyword);
g_free (value);
valid = gtk_tree_model_iter_next (model, &iter);
}
/* A floating GVariant is returned, which is consumed by the g_settings_set_value() */
v = g_variant_builder_end (&b);
g_settings_set_value (ui->settings, CONF_KEY_TEMPLATE_PLACEHOLDERS, v);
}
示例10: start_service_by_name
static gboolean
start_service_by_name(void)
{
GError *error = NULL;
GVariant *var;
GDBusConnection *conn;
conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
if (error) {
fprintf(stderr, "Could not get session bus connection: %s\n",
error->message);
g_error_free(error);
return FALSE;
}
var = g_dbus_connection_call_sync(conn,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"StartServiceByName",
g_variant_new("(su)",
"org.lightmediascanner", 0),
G_VARIANT_TYPE("(u)"),
G_DBUS_CALL_FLAGS_NONE,
10000,
NULL,
&error);
g_object_unref(conn);
if (var)
g_variant_unref(var);
if (error) {
fprintf(stderr, "Could not start org.lightmediascanner: %s\n",
error->message);
g_error_free(error);
return FALSE;
}
return TRUE;
}
示例11: g_dbus_object_manager_server_emit_interfaces_added
static void
g_dbus_object_manager_server_emit_interfaces_added (GDBusObjectManagerServer *manager,
RegistrationData *data,
const gchar *const *interfaces)
{
GVariantBuilder array_builder;
GError *error;
guint n;
const gchar *object_path;
if (data->manager->priv->connection == NULL)
goto out;
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("a{sa{sv}}"));
for (n = 0; interfaces[n] != NULL; n++)
{
GDBusInterfaceSkeleton *iface;
iface = g_hash_table_lookup (data->map_iface_name_to_iface, interfaces[n]);
g_assert (iface != NULL);
g_variant_builder_add_value (&array_builder,
g_variant_new ("{[email protected]{sv}}",
interfaces[n],
g_dbus_interface_skeleton_get_properties (iface)));
}
error = NULL;
object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object));
g_dbus_connection_emit_signal (data->manager->priv->connection,
NULL, /* destination_bus_name */
manager->priv->object_path,
manager_interface_info.name,
"InterfacesAdded",
g_variant_new ("(oa{sa{sv}})",
object_path,
&array_builder),
&error);
g_assert_no_error (error);
out:
;
}
示例12: register_display
static gboolean
register_display (State *state,
GCancellable *cancellable)
{
GdmDBusManager *manager = NULL;
GError *error = NULL;
gboolean registered = FALSE;
GVariantBuilder details;
manager = gdm_dbus_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
"org.gnome.DisplayManager",
"/org/gnome/DisplayManager/Manager",
cancellable,
&error);
if (!manager) {
g_debug ("could not contact display manager: %s", error->message);
g_error_free (error);
goto out;
}
g_variant_builder_init (&details, G_VARIANT_TYPE ("a{ss}"));
g_variant_builder_add (&details, "{ss}", "session-type", "x11");
g_variant_builder_add (&details, "{ss}", "x11-display-name", state->display_name);
registered = gdm_dbus_manager_call_register_display_sync (manager,
g_variant_builder_end (&details),
cancellable,
&error);
if (error != NULL) {
g_debug ("Could not register display: %s", error->message);
g_error_free (error);
}
out:
g_clear_object (&manager);
return registered;
}
示例13: xfpm_dbus_register_name
gboolean xfpm_dbus_register_name(GDBusConnection *connection, const gchar *name)
{
GError *error = NULL;
guint32 ret = 0;
GVariant *var;
var = g_dbus_connection_call_sync (connection,
"org.freedesktop.DBus", /* bus name */
"/org/freedesktop/DBus", /* object path */
"org.freedesktop.DBus", /* interface name */
"RequestName", /* method name */
g_variant_new ("(su)",
name,
0x4), /* DBUS_NAME_FLAG_DO_NOT_QUEUE */
G_VARIANT_TYPE ("(u)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
if (var)
{
g_variant_get (var, "(u)", &ret);
g_variant_unref (var);
}
if ( error )
{
g_warning("Error: %s\n",error->message);
g_error_free(error);
return FALSE;
}
if ( ret == 1 ) /* DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER */
{
return TRUE;
}
return FALSE;
}
示例14: mm_location_gps_raw_get_dictionary
GVariant *
mm_location_gps_raw_get_dictionary (MMLocationGpsRaw *self)
{
GVariantBuilder builder;
/* We do allow NULL */
if (!self)
return NULL;
g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self), NULL);
/* If mandatory parameters are not found, return NULL */
if (!self->priv->utc_time ||
self->priv->longitude == MM_LOCATION_LONGITUDE_UNKNOWN ||
self->priv->latitude == MM_LOCATION_LATITUDE_UNKNOWN)
return NULL;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_UTC_TIME,
g_variant_new_string (self->priv->utc_time));
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_LONGITUDE,
g_variant_new_double (self->priv->longitude));
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_LATITUDE,
g_variant_new_double (self->priv->latitude));
/* Altitude is optional */
if (self->priv->altitude != MM_LOCATION_ALTITUDE_UNKNOWN)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_ALTITUDE,
g_variant_new_double (self->priv->altitude));
return g_variant_ref_sink (g_variant_builder_end (&builder));
}
示例15: update_realms
/* Reconstruct all data about known realms when the global "Realms"
property changes.
*/
static void
update_realms (Realms *realms)
{
if (realms->n_ready != realms->n_realms)
{
realms->need_realm_update = TRUE;
return;
}
gs_unref_variant GVariant *r = g_dbus_proxy_get_cached_property (realms->realmd, "Realms");
if (r && g_variant_is_of_type (r, G_VARIANT_TYPE("ao")))
{
realm_data_free (realms->n_realms, realms->data);
realms->n_realms = g_variant_n_children (r);
realms->n_ready = 0;
realms->data = g_new0 (RealmData, realms->n_realms);
int i;
for (i = 0; i < realms->n_realms; i++)
{
RealmData *data = realms->data + i;
data->owner = realms;
const gchar *path;
g_variant_get_child (r, i, "&o", &path);
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
0,
NULL,
"org.freedesktop.realmd",
path,
"org.freedesktop.realmd.Realm",
NULL,
on_realm_proxy_ready,
data);
}
}
}