コード例 #1
0
static gboolean
import_environment (State        *state,
                    GCancellable *cancellable)
{
        g_autoptr(GVariant) reply = NULL;
        g_autoptr(GVariant) environment_variant = NULL;
        g_autoptr(GError)   error = NULL;

        reply = g_dbus_connection_call_sync (state->bus_connection,
                                             "org.freedesktop.systemd1",
                                             "/org/freedesktop/systemd1",
                                             "org.freedesktop.DBus.Properties",
                                             "Get",
                                             g_variant_new ("(ss)",
                                                            "org.freedesktop.systemd1.Manager",
                                                            "Environment"),
                                             NULL,
                                             G_DBUS_CALL_FLAGS_NONE,
                                             -1, cancellable, &error);

        if (reply == NULL) {
                g_debug ("could not fetch environment: %s", error->message);
                return FALSE;
        }

        g_variant_get (reply, "(v)", &environment_variant);

        state->environment = g_variant_dup_strv (environment_variant, NULL);

        return TRUE;
}
コード例 #2
0
ファイル: setting.c プロジェクト: tschaefer/loom
static void
parse_configuration (Setting *setting)
{
  GVariantDict *dict = NULL;
  GVariant *value = NULL;
  LoomSetting *loom_setting = LOOM_SETTING (setting);

  dict = g_variant_dict_new (setting->configuration);
  value = g_variant_dict_lookup_value (dict, "address", G_VARIANT_TYPE_STRING);
  loom_setting_set_address (loom_setting, g_variant_get_string (value, NULL));

  if (g_variant_dict_contains (dict, "router"))
    {
      value = g_variant_dict_lookup_value (dict, "router",
                                           G_VARIANT_TYPE_STRING);
      loom_setting_set_router (loom_setting, g_variant_get_string (value, NULL));
    }

  if (g_variant_dict_contains (dict, "nameservers"))
    {
      value = g_variant_dict_lookup_value (dict, "nameservers",
                                           G_VARIANT_TYPE_STRING_ARRAY);
      gchar **strv = g_variant_dup_strv (value, NULL);
      loom_setting_set_name_servers (loom_setting, (const gchar **)strv);
      g_strfreev (strv);
    }

  if (g_variant_dict_contains (dict, "domain"))
    {
      value = g_variant_dict_lookup_value (dict, "domains",
                                           G_VARIANT_TYPE_STRING);
      loom_setting_set_domain (loom_setting, g_variant_get_string (value, NULL));
    }

  if (g_variant_dict_contains (dict, "searches"))
    {
      value = g_variant_dict_lookup_value (dict, "searches",
                                           G_VARIANT_TYPE_STRING_ARRAY);
      gchar **strv = g_variant_dup_strv (value, NULL);
      loom_setting_set_searches (loom_setting, (const gchar **)strv);
      g_strfreev (strv);
    }

  g_variant_dict_unref (dict);
}
コード例 #3
0
ファイル: gs-plugin-snap.c プロジェクト: GNOME/gnome-software
static void
load_auth (GsPlugin *plugin)
{
	GsPluginData *priv = gs_plugin_get_data (plugin);
	GsAuth *auth;
	GoaObject *goa_object;
	GoaPasswordBased *password_based;
	g_autofree gchar *macaroon = NULL;
	g_autofree gchar *discharges_str = NULL;
	g_autoptr(GVariant) discharges_var = NULL;
	g_auto(GStrv) discharges = NULL;
	g_autoptr(SnapdAuthData) auth_data = NULL;
	g_autoptr(GError) error = NULL;

	auth = gs_plugin_get_auth_by_id (plugin, "snapd");
	if (auth == NULL)
		return;

	g_clear_object (&priv->auth_data);
	goa_object = gs_auth_peek_goa_object (auth);
	if (goa_object == NULL)
		return;

	password_based = goa_object_peek_password_based (goa_object);
	g_return_if_fail (password_based != NULL);

	goa_password_based_call_get_password_sync (password_based,
						   "macaroon",
						   &macaroon,
						   NULL, &error);
	if (error != NULL) {
		g_warning ("Failed to get macaroon: %s", error->message);
		return;
	}

	goa_password_based_call_get_password_sync (password_based,
						   "discharges",
						   &discharges_str,
						   NULL, &error);
	if (error != NULL) {
		g_warning ("Failed to get discharges %s", error->message);
		return;
	}

	if (discharges_str)
		discharges_var = g_variant_parse (G_VARIANT_TYPE ("as"),
						  discharges_str,
						  NULL, NULL, NULL);
	if (discharges_var)
		discharges = g_variant_dup_strv (discharges_var, NULL);

	priv->auth_data = snapd_auth_data_new (macaroon, discharges);
}
コード例 #4
0
void connman_service_update_properties(connman_service_t *service, GVariant *properties)
{
	if(NULL == service || NULL == properties)
		return;

	gsize i;
	
	for (i = 0; i < g_variant_n_children(properties); i++)
	{
		GVariant *property = g_variant_get_child_value(properties, i);
		GVariant *key_v = g_variant_get_child_value(property, 0);
		GVariant *val_v = g_variant_get_child_value(property, 1);
		GVariant *val = g_variant_get_variant(val_v);
		const gchar *key = g_variant_get_string(key_v, NULL);
		if (g_str_equal(key, "Name"))
		{
			g_free(service->name);
			service->name =  g_variant_dup_string(val, NULL);
		}
		else if (g_str_equal(key, "Type"))
		{
			const gchar *v = g_variant_get_string(val, NULL);

			if (g_str_equal(v, "wifi"))
				service->type = CONNMAN_SERVICE_TYPE_WIFI;

			if (g_str_equal(v, "ethernet"))
				service->type = CONNMAN_SERVICE_TYPE_ETHERNET;
		}
		else if (g_str_equal(key, "State"))
		{
			g_free(service->state);
			service->state =  g_variant_dup_string(val, NULL);
			// Only a hidden service gets added as a new service with "association" state
			if(g_str_equal(service->state, "association"))
				service->hidden = TRUE;
		}
		else if (g_str_equal(key, "Strength"))
			service->strength = g_variant_get_byte(val);
		else if(g_str_equal(key, "Security"))
		{
			g_strfreev(service->security);
			service->security = g_variant_dup_strv(val, NULL);
		}
		else if (g_str_equal(key, "AutoConnect"))
			service->auto_connect = g_variant_get_boolean(val);
		else if (g_str_equal(key, "Immutable"))
			service->immutable = g_variant_get_boolean(val);
		else if (g_str_equal(key, "Favorite"))
			service->favorite = g_variant_get_boolean(val);
	}
}
コード例 #5
0
static GSList *
add_domains (GSList *items,
             GVariant *dict,
             const char *prefix,
             const char four_or_six)
{
	GVariant *val;

	/* Search domains */
	val = g_variant_lookup_value (dict, "domains", G_VARIANT_TYPE_STRING_ARRAY);
	if (val) {
		items = _list_append_val_strv (items, g_variant_dup_strv (val, NULL),
		                               "%sIP%c_DOMAINS=", prefix, four_or_six);
		g_variant_unref (val);
	}
	return items;
}
コード例 #6
0
static gboolean
photos_thumbnailer_handle_generate_thumbnail (PhotosThumbnailer *self,
                                              GDBusMethodInvocation *invocation,
                                              const gchar *uri,
                                              const gchar *mime_type,
                                              const gchar *orientation,
                                              gint64 original_height,
                                              gint64 original_width,
                                              GVariant *pipeline_uris_variant,
                                              const gchar *thumbnail_path,
                                              gint thumbnail_size)
{
  g_autoptr (GCancellable) cancellable = NULL;
  g_auto (GStrv) pipeline_uris = NULL;

  g_return_val_if_fail (PHOTOS_IS_THUMBNAILER (self), FALSE);
  g_return_val_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation), FALSE);
  g_return_val_if_fail (uri != NULL && uri[0] != '\0', FALSE);
  g_return_val_if_fail (mime_type != NULL && mime_type[0] != '\0', FALSE);
  g_return_val_if_fail (orientation != NULL && orientation[0] != '\0', FALSE);
  g_return_val_if_fail (g_variant_is_of_type (pipeline_uris_variant, G_VARIANT_TYPE ("as")), FALSE);
  g_return_val_if_fail (thumbnail_path != NULL && thumbnail_path[0] != '\0', FALSE);

  photos_debug (PHOTOS_DEBUG_THUMBNAILER, "Handling GenerateThumbnail for %s", uri);

  pipeline_uris = g_variant_dup_strv (pipeline_uris_variant, NULL);

  cancellable = g_cancellable_new ();
  g_hash_table_insert (self->cancellables, g_object_ref (invocation), g_object_ref (cancellable));

  g_application_hold (G_APPLICATION (self));
  photos_thumbnailer_generate_thumbnail_async (self,
                                               uri,
                                               mime_type,
                                               orientation,
                                               original_height,
                                               original_width,
                                               (const gchar *const *) pipeline_uris,
                                               thumbnail_path,
                                               thumbnail_size,
                                               cancellable,
                                               photos_thumbnailer_handle_generate_thumbnail_generate_thumbnail,
                                               g_object_ref (invocation));

  return TRUE;
}
コード例 #7
0
ファイル: neardal_tag.c プロジェクト: ABonnemains/neardal
/*****************************************************************************
 * neardal_tag_prv_read_properties: Get Neard Tag Properties
 ****************************************************************************/
static errorCode_t neardal_tag_prv_read_properties(TagProp *tagProp)
{
	errorCode_t	err		= NEARDAL_SUCCESS;
	GVariant	*tmp		= NULL;
	GVariant	*tmpOut		= NULL;
	gsize		len;

	NEARDAL_TRACEIN();
	NEARDAL_ASSERT_RET(tagProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
	NEARDAL_ASSERT_RET(tagProp->proxy != NULL
			  , NEARDAL_ERROR_GENERAL_ERROR);

	tmp = g_datalist_get_data(&(neardalMgr.dbus_data), tagProp->name);
	if (tmp == NULL) {
		err = NEARDAL_ERROR_NO_TAG;
		NEARDAL_TRACE_ERR("Unable to read tag's properties\n");
		goto exit;
	}
	NEARDAL_TRACEF("Reading:\n%s\n", g_variant_print(tmp, TRUE));

	tmpOut = g_variant_lookup_value(tmp, "TagType", G_VARIANT_TYPE_ARRAY);
	if (tmpOut != NULL) {
		tagProp->tagType = g_variant_dup_strv(tmpOut, &len);
		tagProp->tagTypeLen = len;
		if (len == 0) {
			g_strfreev(tagProp->tagType);
			tagProp->tagType = NULL;
		}
	}

	tmpOut = g_variant_lookup_value(tmp, "Type", G_VARIANT_TYPE_STRING);
	if (tmpOut != NULL)
		tagProp->type = g_variant_dup_string(tmpOut, NULL);

	tmpOut = g_variant_lookup_value(tmp, "ReadOnly",
					G_VARIANT_TYPE_BOOLEAN);
	if (tmpOut != NULL)
		tagProp->readOnly = g_variant_get_boolean(tmpOut);

exit:
	return err;
}
コード例 #8
0
Bool
appendToPluginsWithSetKeysList (const gchar *plugin,
				GVariant    *writtenPlugins,
				char	       ***newWrittenPlugins,
				gsize	       *newWrittenPluginsSize)
{
    gsize writtenPluginsLen = 0;
    Bool            found = FALSE;
    char	    *plug;
    GVariantIter    iter;

    g_variant_iter_init (&iter, writtenPlugins);
    *newWrittenPluginsSize = g_variant_iter_n_children (&iter);

    while (g_variant_iter_loop (&iter, "s", &plug))
    {
	if (!found)
	    found = (g_strcmp0 (plug, plugin) == 0);
    }

    if (!found)
	++(*newWrittenPluginsSize);

    *newWrittenPlugins = g_variant_dup_strv (writtenPlugins, &writtenPluginsLen);

    if (*newWrittenPluginsSize > writtenPluginsLen)
    {
	*newWrittenPlugins = g_realloc (*newWrittenPlugins, (*newWrittenPluginsSize + 1) * sizeof (gchar *));

	/* Next item becomes plugin */
	(*newWrittenPlugins)[writtenPluginsLen]  = g_strdup (plugin);

	/* Last item becomes NULL */
	(*newWrittenPlugins)[*newWrittenPluginsSize] = NULL;
    }

    return !found;
}
コード例 #9
0
gboolean connman_service_get_ipinfo(connman_service_t *service)
{
	if(NULL == service)
		return FALSE;

	GError *error = NULL;
	GVariant *properties;
	gsize i;

	connman_interface_service_call_get_properties_sync(service->remote, &properties, NULL, &error);
	if (error)
	{
		WCA_LOG_CRITICAL("Error: %s", error->message);
		g_error_free(error);
		return FALSE;
	}

	for (i = 0; i < g_variant_n_children(properties); i++)
	{
		GVariant *property = g_variant_get_child_value(properties, i);
		GVariant *key_v = g_variant_get_child_value(property, 0);
		const gchar *key = g_variant_get_string(key_v, NULL);

		if (g_str_equal(key, "Ethernet"))
		{
			GVariant *v = g_variant_get_child_value(property, 1);
			GVariant *va = g_variant_get_child_value(v, 0);
			gsize j;
			for(j = 0; j < g_variant_n_children(va); j++)
	  		{
				GVariant *ethernet = g_variant_get_child_value(va, j);
				GVariant *ekey_v = g_variant_get_child_value(ethernet, 0);
				const gchar *ekey = g_variant_get_string(ekey_v, NULL);

				if(g_str_equal(ekey, "Interface"))
				{
					GVariant *ifacev = g_variant_get_child_value(ethernet, 1);
					GVariant *ifaceva = g_variant_get_variant(ifacev);
					g_free(service->ipinfo.iface);
					service->ipinfo.iface = g_variant_dup_string(ifaceva, NULL);
				}
	  		}
		}
		if(g_str_equal(key, "IPv4"))
		{
			GVariant *v = g_variant_get_child_value(property, 1);
			GVariant *va = g_variant_get_child_value(v, 0);
			gsize j;
			for(j = 0; j < g_variant_n_children(va); j++)
			{
				GVariant *ipv4 = g_variant_get_child_value(va, j);
				GVariant *ikey_v = g_variant_get_child_value(ipv4, 0);
				const gchar *ikey = g_variant_get_string(ikey_v, NULL);
				if(g_str_equal(ikey, "Method"))
				{
					GVariant *netmaskv = g_variant_get_child_value(ipv4, 1);
					GVariant *netmaskva = g_variant_get_variant(netmaskv);
					g_free(service->ipinfo.ipv4.method);
					service->ipinfo.ipv4.method = g_variant_dup_string(netmaskva, NULL);
				}
				if(g_str_equal(ikey, "Netmask"))
				{
					GVariant *netmaskv = g_variant_get_child_value(ipv4, 1);
					GVariant *netmaskva = g_variant_get_variant(netmaskv);
					g_free(service->ipinfo.ipv4.netmask);
					service->ipinfo.ipv4.netmask = g_variant_dup_string(netmaskva, NULL);
				}
				if(g_str_equal(ikey, "Address"))
				{
					GVariant *addressv = g_variant_get_child_value(ipv4, 1);
					GVariant *addressva = g_variant_get_variant(addressv);
					g_free(service->ipinfo.ipv4.address);
					service->ipinfo.ipv4.address = g_variant_dup_string(addressva, NULL);
				}
				if(g_str_equal(ikey, "Gateway"))
				{
					GVariant *gatewayv = g_variant_get_child_value(ipv4, 1);
					GVariant *gatewayva = g_variant_get_variant(gatewayv);
					g_free(service->ipinfo.ipv4.gateway);
					service->ipinfo.ipv4.gateway = g_variant_dup_string(gatewayva, NULL);
				}
			  }
			}
		if(g_str_equal(key, "Nameservers"))
		{
			GVariant *v = g_variant_get_child_value(property, 1);
			GVariant *va = g_variant_get_child_value(v, 0);
			g_strfreev(service->ipinfo.dns);
			service->ipinfo.dns = g_variant_dup_strv(va, NULL);
		}
	}
	return TRUE;
}
コード例 #10
0
ファイル: cd-profile.c プロジェクト: Hextremist/colord
static void
cd_profile_connect_cb (GObject *source_object,
		       GAsyncResult *res,
		       gpointer user_data)
{
	CdProfile *profile;
	CdProfilePrivate *priv;
	g_autoptr(GError) error = NULL;
	g_autoptr(GTask) task = G_TASK (user_data);
	g_autoptr(GVariant) colorspace = NULL;
	g_autoptr(GVariant) created = NULL;
	g_autoptr(GVariant) filename = NULL;
	g_autoptr(GVariant) format = NULL;
	g_autoptr(GVariant) has_vcgt = NULL;
	g_autoptr(GVariant) id = NULL;
	g_autoptr(GVariant) is_system_wide = NULL;
	g_autoptr(GVariant) kind = NULL;
	g_autoptr(GVariant) metadata = NULL;
	g_autoptr(GVariant) owner = NULL;
	g_autoptr(GVariant) qualifier = NULL;
	g_autoptr(GVariant) scope = NULL;
	g_autoptr(GVariant) title = NULL;
	g_autoptr(GVariant) warnings = NULL;

	profile = CD_PROFILE (g_task_get_source_object (task));
	priv = GET_PRIVATE (profile);
	priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
	if (priv->proxy == NULL) {
		g_task_return_new_error (task,
						 CD_PROFILE_ERROR,
						 CD_PROFILE_ERROR_INTERNAL,
						 "Failed to connect to profile %s: %s",
						 cd_profile_get_object_path (profile),
						 error->message);
		return;
	}

	/* get profile id */
	id = g_dbus_proxy_get_cached_property (priv->proxy,
					       CD_PROFILE_PROPERTY_ID);
	if (id != NULL)
		priv->id = g_variant_dup_string (id, NULL);

	/* if the profile is missing, then fail */
	if (id == NULL) {
		g_task_return_new_error (task,
						 CD_PROFILE_ERROR,
						 CD_PROFILE_ERROR_INTERNAL,
						 "Failed to connect to missing profile %s",
						 cd_profile_get_object_path (profile));
		return;
	}

	/* get filename */
	filename = g_dbus_proxy_get_cached_property (priv->proxy,
						     CD_PROFILE_PROPERTY_FILENAME);
	if (filename != NULL)
		priv->filename = cd_profile_get_nullable_str (filename);

	/* get qualifier */
	qualifier = g_dbus_proxy_get_cached_property (priv->proxy,
						      CD_PROFILE_PROPERTY_QUALIFIER);
	if (qualifier != NULL)
		priv->qualifier = cd_profile_get_nullable_str (qualifier);

	/* get format */
	format = g_dbus_proxy_get_cached_property (priv->proxy,
						   CD_PROFILE_PROPERTY_FORMAT);
	if (format != NULL)
		priv->format = cd_profile_get_nullable_str (format);

	/* get title */
	title = g_dbus_proxy_get_cached_property (priv->proxy,
						  CD_PROFILE_PROPERTY_TITLE);
	if (title != NULL)
		priv->title = cd_profile_get_nullable_str (title);

	/* get kind */
	kind = g_dbus_proxy_get_cached_property (priv->proxy,
						 CD_PROFILE_PROPERTY_KIND);
	if (kind != NULL)
		priv->kind = cd_profile_kind_from_string (g_variant_get_string (kind, NULL));

	/* get colorspace */
	colorspace = g_dbus_proxy_get_cached_property (priv->proxy,
						       CD_PROFILE_PROPERTY_COLORSPACE);
	if (colorspace != NULL)
		priv->colorspace = cd_colorspace_from_string (g_variant_get_string (colorspace, NULL));

	/* get scope */
	scope = g_dbus_proxy_get_cached_property (priv->proxy,
						  CD_PROFILE_PROPERTY_SCOPE);
	if (scope != NULL)
		priv->scope = cd_object_scope_from_string (g_variant_get_string (scope, NULL));

	/* get owner */
	owner = g_dbus_proxy_get_cached_property (priv->proxy,
						  CD_PROFILE_PROPERTY_OWNER);
	if (owner != NULL)
		priv->owner = g_variant_get_uint32 (owner);

	/* get warnings */
	warnings = g_dbus_proxy_get_cached_property (priv->proxy,
						  CD_PROFILE_PROPERTY_WARNINGS);
	if (warnings != NULL)
		priv->warnings = g_variant_dup_strv (warnings, NULL);

	/* get created */
	created = g_dbus_proxy_get_cached_property (priv->proxy,
						    CD_PROFILE_PROPERTY_CREATED);
	if (created != NULL)
		priv->created = g_variant_get_int64 (created);

	/* get VCGT */
	has_vcgt = g_dbus_proxy_get_cached_property (priv->proxy,
						     CD_PROFILE_PROPERTY_HAS_VCGT);
	if (has_vcgt != NULL)
		priv->has_vcgt = g_variant_get_boolean (has_vcgt);

	/* get if system wide */
	is_system_wide = g_dbus_proxy_get_cached_property (priv->proxy,
							   CD_PROFILE_PROPERTY_IS_SYSTEM_WIDE);
	if (is_system_wide != NULL)
		priv->is_system_wide = g_variant_get_boolean (is_system_wide);

	/* get if system wide */
	metadata = g_dbus_proxy_get_cached_property (priv->proxy,
						     CD_PROFILE_PROPERTY_METADATA);
	if (metadata != NULL)
		cd_profile_set_metadata_from_variant (profile, metadata);

	/* get signals from DBus */
	g_signal_connect_object (priv->proxy,
				 "g-signal",
				 G_CALLBACK (cd_profile_dbus_signal_cb),
				 profile, 0);

	/* watch if any remote properties change */
	g_signal_connect_object (priv->proxy,
				 "g-properties-changed",
				 G_CALLBACK (cd_profile_dbus_properties_changed_cb),
				 profile, 0);

	/* success */
	g_task_return_boolean (task, TRUE);
}
コード例 #11
0
ファイル: cd-profile.c プロジェクト: Hextremist/colord
/**
 * cd_profile_dbus_properties_changed_cb:
 **/
static void
cd_profile_dbus_properties_changed_cb (GDBusProxy  *proxy,
				    GVariant    *changed_properties,
				    const gchar * const *invalidated_properties,
				    CdProfile   *profile)
{
	CdProfilePrivate *priv = GET_PRIVATE (profile);
	guint i;
	guint len;
	GVariantIter iter;
	gchar *property_name;
	GVariant *property_value;

	g_return_if_fail (CD_IS_PROFILE (profile));

	len = g_variant_iter_init (&iter, changed_properties);
	for (i = 0; i < len; i++) {
		g_variant_get_child (changed_properties, i,
				     "{sv}",
				     &property_name,
				     &property_value);
		if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_QUALIFIER) == 0) {
			g_free (priv->qualifier);
			priv->qualifier = cd_profile_get_nullable_str (property_value);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_FORMAT) == 0) {
			g_free (priv->format);
			priv->format = cd_profile_get_nullable_str (property_value);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_FILENAME) == 0) {
			g_free (priv->filename);
			priv->filename = cd_profile_get_nullable_str (property_value);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_ID) == 0) {
			g_free (priv->id);
			priv->id = g_variant_dup_string (property_value, NULL);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_TITLE) == 0) {
			g_free (priv->title);
			priv->title = g_variant_dup_string (property_value, NULL);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_WARNINGS) == 0) {
			g_strfreev(priv->warnings);
			priv->warnings = g_variant_dup_strv (property_value, NULL);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_KIND) == 0) {
			priv->kind = cd_profile_kind_from_string (g_variant_get_string (property_value, NULL));
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_COLORSPACE) == 0) {
			priv->colorspace = cd_colorspace_from_string (g_variant_get_string (property_value, NULL));
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_SCOPE) == 0) {
			priv->scope = cd_object_scope_from_string (g_variant_get_string (property_value, NULL));
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_CREATED) == 0) {
			priv->created = g_variant_get_int64 (property_value);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_HAS_VCGT) == 0) {
			priv->has_vcgt = g_variant_get_boolean (property_value);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_OWNER) == 0) {
			priv->owner = g_variant_get_uint32 (property_value);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_IS_SYSTEM_WIDE) == 0) {
			priv->is_system_wide = g_variant_get_boolean (property_value);
		} else if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_METADATA) == 0) {
			cd_profile_set_metadata_from_variant (profile, property_value);
		} else {
			g_warning ("%s property unhandled", property_name);
		}
		g_free (property_name);
		g_variant_unref (property_value);
	}
}
コード例 #12
0
static gboolean on_GetNDEF(neardalNDEFAgent             *ndefAgent,
                           GDBusMethodInvocation       *invocation
                           , GVariant                   *values
                           , gpointer                   user_data)
{
	neardal_ndef_agent_t	*agent_data	= user_data;
	gchar			**rcdArray	= NULL;
	gsize			rcdLen		= 0;
	gchar			*ndefArray	= NULL;
	gsize			ndefLen		= 0;
	gconstpointer		value;

	(void) ndefAgent;       /* Avoid warning */
	(void) invocation;      /* Avoid warning */

	NEARDAL_TRACEIN();
	NEARDAL_TRACEF("%s\n", g_variant_print(values, TRUE));

	if (agent_data != NULL) {
		NEARDAL_TRACEF("ndefAgent pid=%d, obj path is : %s\n"
			      , agent_data->pid
			      , agent_data->objPath);
		if (agent_data->cb_ndef_agent != NULL) {
			GVariant	*tmpOut	 = NULL;

			tmpOut = g_variant_lookup_value(values, "Records",
							G_VARIANT_TYPE_ARRAY);
			if (tmpOut != NULL) {
				rcdArray = (gchar**) g_variant_dup_strv(tmpOut
								, &rcdLen);

				if (rcdLen == 0) {
					g_strfreev(rcdArray);
					rcdArray = NULL;
				}
			}
			tmpOut = g_variant_lookup_value(values, "NDEF",
							G_VARIANT_TYPE_ARRAY);
			if (tmpOut != NULL) {
				value = g_variant_get_data(tmpOut);
				ndefLen = g_variant_get_size(tmpOut);

				if (ndefLen > 0) {
					ndefArray = g_try_malloc0(ndefLen);
					if (ndefArray != NULL)
						memcpy(ndefArray, value
						      , ndefLen);
				}
			}
			(agent_data->cb_ndef_agent)(
					(unsigned char **) rcdArray
					, rcdLen
					, (unsigned char *) ndefArray
					, ndefLen
					, agent_data->user_data);
			g_free(ndefArray);
			g_strfreev(rcdArray);
		}
	}

	return TRUE;
}
コード例 #13
0
ファイル: dbus.c プロジェクト: DSMan195276/dunst
static void onNotify(GDBusConnection * connection,
                     const gchar * sender,
                     GVariant * parameters, GDBusMethodInvocation * invocation)
{

        gchar *appname = NULL;
        guint replaces_id = 0;
        gchar *icon = NULL;
        gchar *summary = NULL;
        gchar *body = NULL;
        Actions *actions = malloc(sizeof(Actions));
        gint timeout = -1;

        /* hints */
        gint urgency = 1;
        gint progress = -1;
        gchar *fgcolor = NULL;
        gchar *bgcolor = NULL;
        gchar *category = NULL;

        actions->actions = NULL;
        actions->count = 0;

        {
                GVariantIter *iter = g_variant_iter_new(parameters);
                GVariant *content;
                GVariant *dict_value;
                int idx = 0;
                while ((content = g_variant_iter_next_value(iter))) {

                        switch (idx) {
                        case 0:
                                if (g_variant_is_of_type
                                    (content, G_VARIANT_TYPE_STRING))
                                        appname =
                                            g_variant_dup_string(content, NULL);
                                break;
                        case 1:
                                if (g_variant_is_of_type
                                    (content, G_VARIANT_TYPE_UINT32))
                                        replaces_id =
                                            g_variant_get_uint32(content);
                                break;
                        case 2:
                                if (g_variant_is_of_type
                                    (content, G_VARIANT_TYPE_STRING))
                                        icon =
                                            g_variant_dup_string(content, NULL);
                                break;
                        case 3:
                                if (g_variant_is_of_type
                                    (content, G_VARIANT_TYPE_STRING))
                                        summary =
                                            g_variant_dup_string(content, NULL);
                                break;
                        case 4:
                                if (g_variant_is_of_type
                                    (content, G_VARIANT_TYPE_STRING))
                                        body =
                                            g_variant_dup_string(content, NULL);
                                break;
                        case 5:
                                if (g_variant_is_of_type
                                    (content, G_VARIANT_TYPE_STRING_ARRAY))
                                        actions->actions =
                                            g_variant_dup_strv(content,
                                                               &(actions->
                                                                 count));
                                break;
                        case 6:
                                if (g_variant_is_of_type
                                    (content, G_VARIANT_TYPE_DICTIONARY)) {

                                        dict_value =
                                            g_variant_lookup_value(content,
                                                                   "urgency",
                                                                   G_VARIANT_TYPE_BYTE);
                                        if (dict_value)
                                                urgency =
                                                    g_variant_get_byte
                                                    (dict_value);

                                        dict_value =
                                            g_variant_lookup_value(content,
                                                                   "fgcolor",
                                                                   G_VARIANT_TYPE_STRING);
                                        if (dict_value)
                                                fgcolor =
                                                    g_variant_dup_string
                                                    (dict_value, NULL);

                                        dict_value =
                                            g_variant_lookup_value(content,
                                                                   "bgcolor",
                                                                   G_VARIANT_TYPE_STRING);
                                        if (dict_value)
                                                bgcolor =
                                                    g_variant_dup_string
                                                    (dict_value, NULL);

                                        dict_value =
                                                g_variant_lookup_value(content,
                                                                "category",
                                                                G_VARIANT_TYPE_STRING);

                                        if (dict_value) {
                                                category =
                                                        g_variant_dup_string(
                                                                        dict_value, NULL);
                                        }

                                        dict_value =
                                                g_variant_lookup_value(content,
                                                                "value",
                                                                G_VARIANT_TYPE_INT32);

                                        if (dict_value) {
                                                progress =
                                                        g_variant_get_int32(dict_value);
                                        } else {
                                                dict_value =
                                                        g_variant_lookup_value(content,
                                                                        "value",
                                                                        G_VARIANT_TYPE_UINT32);

                                                if (dict_value)
                                                        progress =
                                                                g_variant_get_uint32(dict_value);
                                        }
                                }
                                break;
                        case 7:
                                if (g_variant_is_of_type
                                    (content, G_VARIANT_TYPE_INT32))
                                        timeout = g_variant_get_int32(content);
                                break;
                        }

                        idx++;
                }

                g_variant_iter_free(iter);
        }

        fflush(stdout);

        if (timeout > 0) {
                /* do some rounding */
                timeout = (timeout + 500) / 1000;
                if (timeout < 1) {
                        timeout = 1;
                }
        }

        notification *n = malloc(sizeof(notification));
        n->appname = appname;
        n->summary = summary;
        n->body = body;
        n->icon = icon;
        n->timeout = timeout;
        n->progress = (progress < 0 || progress > 100) ? 0 : progress + 1;
        n->urgency = urgency;
        n->category = category;
        n->dbus_client = strdup(sender);
        if (actions->count > 0) {
                n->actions = actions;
        } else {
                n->actions = NULL;
                free(actions);
        }

        for (int i = 0; i < ColLast; i++) {
                n->color_strings[i] = NULL;
        }
        n->color_strings[ColFG] = fgcolor;
        n->color_strings[ColBG] = bgcolor;

        int id = notification_init(n, replaces_id);
        wake_up();

        GVariant *reply = g_variant_new("(u)", id);
        g_dbus_method_invocation_return_value(invocation, reply);
        g_dbus_connection_flush(connection, NULL, NULL, NULL);

        run(NULL);
}
コード例 #14
0
ファイル: gsettings-mapping.c プロジェクト: Andais/glib
gboolean
g_settings_get_mapping (GValue   *value,
                        GVariant *variant,
                        gpointer  user_data)
{
  if (g_variant_is_of_type (variant, G_VARIANT_TYPE_BOOLEAN))
    {
      if (!G_VALUE_HOLDS_BOOLEAN (value))
        return FALSE;
      g_value_set_boolean (value, g_variant_get_boolean (variant));
      return TRUE;
    }

  else if (g_variant_is_of_type (variant, G_VARIANT_TYPE_BYTE))
    {
      if (G_VALUE_HOLDS_UCHAR (value))
        g_value_set_uchar (value, g_variant_get_byte (variant));
      else if (G_VALUE_HOLDS_CHAR (value))
        g_value_set_char (value, (gchar) g_variant_get_byte (variant));
      else
        return FALSE;
      return TRUE;
    }

  else if (g_variant_is_of_type (variant, G_VARIANT_TYPE_INT16)  ||
           g_variant_is_of_type (variant, G_VARIANT_TYPE_INT32)  ||
           g_variant_is_of_type (variant, G_VARIANT_TYPE_INT64))
    return g_settings_get_mapping_int (value, variant);

  else if (g_variant_is_of_type (variant, G_VARIANT_TYPE_DOUBLE))
    return g_settings_get_mapping_float (value, variant);

  else if (g_variant_is_of_type (variant, G_VARIANT_TYPE_UINT16) ||
           g_variant_is_of_type (variant, G_VARIANT_TYPE_UINT32) ||
           g_variant_is_of_type (variant, G_VARIANT_TYPE_UINT64) ||
           g_variant_is_of_type (variant, G_VARIANT_TYPE_HANDLE))
    return g_settings_get_mapping_unsigned_int (value, variant);

  else if (g_variant_is_of_type (variant, G_VARIANT_TYPE_STRING)      ||
           g_variant_is_of_type (variant, G_VARIANT_TYPE_OBJECT_PATH) ||
           g_variant_is_of_type (variant, G_VARIANT_TYPE_SIGNATURE))
    {
      if (G_VALUE_HOLDS_STRING (value))
        {
          g_value_set_string (value, g_variant_get_string (variant, NULL));
          return TRUE;
        }

      else if (G_VALUE_HOLDS_ENUM (value))
        {
          GEnumClass *eclass;
          GEnumValue *evalue;
          const gchar *nick;

          /* GParamSpecEnum holds a ref on the class so we just peek... */
          eclass = g_type_class_peek (G_VALUE_TYPE (value));
          nick = g_variant_get_string (variant, NULL);
          evalue = g_enum_get_value_by_nick (eclass, nick);

          if (evalue)
            {
             g_value_set_enum (value, evalue->value);
             return TRUE;
            }

          g_warning ("Unable to lookup enum nick '%s' via GType\n", nick);
          return FALSE;
        }
    }
  else if (g_variant_is_of_type (variant, G_VARIANT_TYPE ("as")))
    {
      if (G_VALUE_HOLDS (value, G_TYPE_STRV))
        {
          g_value_take_boxed (value, g_variant_dup_strv (variant, NULL));
          return TRUE;
        }

      else if (G_VALUE_HOLDS_FLAGS (value))
        {
          GFlagsClass *fclass;
          GFlagsValue *fvalue;
          const gchar *nick;
          GVariantIter iter;
          guint flags = 0;

          fclass = g_type_class_peek (G_VALUE_TYPE (value));

          g_variant_iter_init (&iter, variant);
          while (g_variant_iter_next (&iter, "&s", &nick))
            {
              fvalue = g_flags_get_value_by_nick (fclass, nick);

              if (fvalue)
                flags |= fvalue->value;

              else
                {
                  g_warning ("Unable to lookup flags nick '%s' via GType\n",
                             nick);
                  return FALSE;
                }
            }

          g_value_set_flags (value, flags);
          return TRUE;
        }
    }
  else if (g_variant_is_of_type (variant, G_VARIANT_TYPE_BYTESTRING))
    {
      g_value_set_string (value, g_variant_get_bytestring (variant));
      return TRUE;
    }

  g_critical ("No GSettings bind handler for type \"%s\".",
              g_variant_get_type_string (variant));

  return FALSE;
}
コード例 #15
0
ファイル: neardal_tag.c プロジェクト: GeorgN/neardal-debian
/*****************************************************************************
 * neardal_tag_prv_read_properties: Get Neard Tag Properties
 ****************************************************************************/
static errorCode_t neardal_tag_prv_read_properties(TagProp *tagProp)
{
	errorCode_t	err		= NEARDAL_SUCCESS;
	GVariant	*tmp		= NULL;
	GVariant	*tmpOut		= NULL;
	gsize		len;

	NEARDAL_TRACEIN();
	NEARDAL_ASSERT_RET(tagProp != NULL, NEARDAL_ERROR_INVALID_PARAMETER);
	NEARDAL_ASSERT_RET(tagProp->proxy != NULL
			  , NEARDAL_ERROR_GENERAL_ERROR);

	tmp = g_datalist_get_data(&(neardalMgr.dbus_data), tagProp->name);
	if (tmp == NULL) {
		err = NEARDAL_ERROR_NO_TAG;
		NEARDAL_TRACE_ERR("Unable to read tag's properties\n");
		goto exit;
	}
	NEARDAL_TRACEF("Reading:\n%s\n", g_variant_print(tmp, TRUE));

	tmpOut = g_variant_lookup_value(tmp, "TagType", G_VARIANT_TYPE_ARRAY);
	if (tmpOut != NULL) {
		tagProp->tagType = g_variant_dup_strv(tmpOut, &len);
		tagProp->tagTypeLen = len;
		if (len == 0) {
			g_strfreev(tagProp->tagType);
			tagProp->tagType = NULL;
		}
	}

	tmpOut = g_variant_lookup_value(tmp, "Type", G_VARIANT_TYPE_STRING);
	if (tmpOut != NULL)
		tagProp->type = g_variant_dup_string(tmpOut, NULL);

	tmpOut = g_variant_lookup_value(tmp, "ReadOnly",
					G_VARIANT_TYPE_BOOLEAN);
	if (tmpOut != NULL)
		tagProp->readOnly = g_variant_get_boolean(tmpOut);

	/* ISO14443A-specific fields (optional) */
	tmpOut = g_variant_lookup_value(tmp, "Iso14443aAtqa",
			G_VARIANT_TYPE_BYTESTRING);
	if ( (tmpOut != NULL) && (g_variant_n_children(tmpOut) > 0) )
		tagProp->iso14443aAtqa = g_variant_get_data_as_bytes(tmpOut);

	tmpOut = g_variant_lookup_value(tmp, "Iso14443aSak",
			G_VARIANT_TYPE_BYTESTRING);
	if ( (tmpOut != NULL) && (g_variant_n_children(tmpOut) > 0) )
		tagProp->iso14443aSak = g_variant_get_data_as_bytes(tmpOut);

	tmpOut = g_variant_lookup_value(tmp, "Iso14443aUid",
			G_VARIANT_TYPE_BYTESTRING);
	if ( (tmpOut != NULL) && (g_variant_n_children(tmpOut) > 0) )
		tagProp->iso14443aUid = g_variant_get_data_as_bytes(tmpOut);

	/* Felica-specific fields (optional) */
	tmpOut = g_variant_lookup_value(tmp, "FelicaManufacturer",
			G_VARIANT_TYPE_BYTESTRING);
	if ( (tmpOut != NULL) && (g_variant_n_children(tmpOut) > 0) )
		tagProp->felicaManufacturer = g_variant_get_data_as_bytes(tmpOut);

	tmpOut = g_variant_lookup_value(tmp, "FelicaCid",
			G_VARIANT_TYPE_BYTESTRING);
	if ( (tmpOut != NULL) && (g_variant_n_children(tmpOut) > 0) )
		tagProp->felicaCid = g_variant_get_data_as_bytes(tmpOut);

	tmpOut = g_variant_lookup_value(tmp, "FelicaIc",
			G_VARIANT_TYPE_BYTESTRING);
	if ( (tmpOut != NULL) && (g_variant_n_children(tmpOut) > 0) )
		tagProp->felicaIc = g_variant_get_data_as_bytes(tmpOut);

	tmpOut = g_variant_lookup_value(tmp, "FelicaMaxRespTimes",
			G_VARIANT_TYPE_BYTESTRING);
	if ( (tmpOut != NULL) && (g_variant_n_children(tmpOut) > 0) )
		tagProp->felicaMaxRespTimes = g_variant_get_data_as_bytes(tmpOut);

exit:
	return err;
}
コード例 #16
0
ファイル: settings.c プロジェクト: tschaefer/loom
static gboolean
validate_configuration (GVariant *configuration,
                        GError **error)
{
  GVariantDict *dict = NULL;
  GVariant *value = NULL;

  dict = g_variant_dict_new (configuration);

  if (g_variant_dict_contains (dict, "address"))
    {
      value = g_variant_dict_lookup_value (dict, "address",
                                           G_VARIANT_TYPE_STRING);
      if (value == NULL)
        {
          g_variant_dict_unref (dict);
          *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                _("'address' entry must be a string"));
          return FALSE;
        }
      if (!validate_address ("address", g_variant_get_string (value, NULL),
                             TRUE, error))
        {
          g_variant_dict_unref (dict);
          return FALSE;
        }
    }
  else
    {
      g_variant_dict_unref (dict);
      *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                            _("'address' entry is required"));
      return FALSE;
    }

  if (g_variant_dict_contains (dict, "router"))
    {
      value = g_variant_dict_lookup_value (dict, "router",
                                           G_VARIANT_TYPE_STRING);
      if (value == NULL)
        {
          g_variant_dict_unref (dict);
          *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                _("'router' entry must be a string"));
          return FALSE;
        }
      if (!validate_address ("router", g_variant_get_string (value, NULL),
                             FALSE, error))
        {
          g_variant_dict_unref (dict);
          return FALSE;
        }
    }

  if (g_variant_dict_contains (dict, "nameservers"))
    {
      value = g_variant_dict_lookup_value (dict, "nameservers",
                                           G_VARIANT_TYPE_STRING_ARRAY);
      if (value == NULL)
        {
          g_variant_dict_unref (dict);
          *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                            _("'nameservers' entry must be a string array"));
          return FALSE;
        }
      gsize len;
      gs_strfreev gchar **nameservers = g_variant_dup_strv (value, &len);
      for (gsize i = 0; i < len; i++)
        {
          if (!validate_address ("nameservers", nameservers[i],
                                 FALSE, error))
            {
              g_variant_dict_unref (dict);
              return FALSE;
            }
        }
    }

  if (g_variant_dict_contains (dict, "domain"))
    {
      value = g_variant_dict_lookup_value (dict, "domain",
                                           G_VARIANT_TYPE_STRING);
      if (value == NULL)
        {
          g_variant_dict_unref (dict);
          *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                _("'domain' entry must be a string"));
          return FALSE;
        }
      if (!validate_domainname ("domain", g_variant_get_string (value, NULL),
                                error))
        {
          g_variant_dict_unref (dict);
          return FALSE;
        }
    }

  if (g_variant_dict_contains (dict, "searches"))
    {
      value = g_variant_dict_lookup_value (dict, "searches",
                                           G_VARIANT_TYPE_STRING_ARRAY);
      if (value == NULL)
        {
          g_variant_dict_unref (dict);
          *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                               _("'searches' entry must be a string array"));

          return FALSE;
        }
      gsize len;
      gs_strfreev gchar **searches = g_variant_dup_strv (value, &len);
      for (gsize i = 0; i < len; i++)
        {
          if (!validate_domainname ("searches", searches[i], error))
            {
              g_variant_dict_unref (dict);
              return FALSE;
            }
        }
    }

  g_variant_dict_unref (dict);

  return TRUE;
}
コード例 #17
0
ファイル: gdbusutils.c プロジェクト: 183amir/glib
/**
 * g_dbus_gvariant_to_gvalue:
 * @value: A #GVariant.
 * @out_gvalue: (out): Return location pointing to a zero-filled (uninitialized) #GValue.
 *
 * Converts a #GVariant to a #GValue. If @value is floating, it is consumed.
 *
 * The rules specified in the g_dbus_gvalue_to_gvariant() function are
 * used - this function is essentially its reverse form.
 *
 * The conversion never fails - a valid #GValue is always returned in
 * @out_gvalue.
 *
 * Since: 2.30
 */
void
g_dbus_gvariant_to_gvalue (GVariant  *value,
                           GValue    *out_gvalue)
{
  const GVariantType *type;
  gchar **array;

  g_return_if_fail (value != NULL);
  g_return_if_fail (out_gvalue != NULL);

  memset (out_gvalue, '\0', sizeof (GValue));

  switch (g_variant_classify (value))
    {
    case G_VARIANT_CLASS_BOOLEAN:
      g_value_init (out_gvalue, G_TYPE_BOOLEAN);
      g_value_set_boolean (out_gvalue, g_variant_get_boolean (value));
      break;

    case G_VARIANT_CLASS_BYTE:
      g_value_init (out_gvalue, G_TYPE_UCHAR);
      g_value_set_uchar (out_gvalue, g_variant_get_byte (value));
      break;

    case G_VARIANT_CLASS_INT16:
      g_value_init (out_gvalue, G_TYPE_INT);
      g_value_set_int (out_gvalue, g_variant_get_int16 (value));
      break;

    case G_VARIANT_CLASS_UINT16:
      g_value_init (out_gvalue, G_TYPE_UINT);
      g_value_set_uint (out_gvalue, g_variant_get_uint16 (value));
      break;

    case G_VARIANT_CLASS_INT32:
      g_value_init (out_gvalue, G_TYPE_INT);
      g_value_set_int (out_gvalue, g_variant_get_int32 (value));
      break;

    case G_VARIANT_CLASS_UINT32:
      g_value_init (out_gvalue, G_TYPE_UINT);
      g_value_set_uint (out_gvalue, g_variant_get_uint32 (value));
      break;

    case G_VARIANT_CLASS_INT64:
      g_value_init (out_gvalue, G_TYPE_INT64);
      g_value_set_int64 (out_gvalue, g_variant_get_int64 (value));
      break;

    case G_VARIANT_CLASS_UINT64:
      g_value_init (out_gvalue, G_TYPE_UINT64);
      g_value_set_uint64 (out_gvalue, g_variant_get_uint64 (value));
      break;

    case G_VARIANT_CLASS_DOUBLE:
      g_value_init (out_gvalue, G_TYPE_DOUBLE);
      g_value_set_double (out_gvalue, g_variant_get_double (value));
      break;

    case G_VARIANT_CLASS_STRING:
      g_value_init (out_gvalue, G_TYPE_STRING);
      g_value_set_string (out_gvalue, g_variant_get_string (value, NULL));
      break;

    case G_VARIANT_CLASS_OBJECT_PATH:
      g_value_init (out_gvalue, G_TYPE_STRING);
      g_value_set_string (out_gvalue, g_variant_get_string (value, NULL));
      break;

    case G_VARIANT_CLASS_SIGNATURE:
      g_value_init (out_gvalue, G_TYPE_STRING);
      g_value_set_string (out_gvalue, g_variant_get_string (value, NULL));
      break;

    case G_VARIANT_CLASS_ARRAY:
      type = g_variant_get_type (value);
      switch (g_variant_type_peek_string (type)[1])
        {
        case G_VARIANT_CLASS_BYTE:
          g_value_init (out_gvalue, G_TYPE_STRING);
          g_value_set_string (out_gvalue, g_variant_get_bytestring (value));
          break;

        case G_VARIANT_CLASS_STRING:
          g_value_init (out_gvalue, G_TYPE_STRV);
          array = g_variant_dup_strv (value, NULL);
          g_value_take_boxed (out_gvalue, array);
          break;

        case G_VARIANT_CLASS_OBJECT_PATH:
          g_value_init (out_gvalue, G_TYPE_STRV);
          array = g_variant_dup_objv (value, NULL);
          g_value_take_boxed (out_gvalue, array);
          break;

        case G_VARIANT_CLASS_ARRAY:
          switch (g_variant_type_peek_string (type)[2])
            {
            case G_VARIANT_CLASS_BYTE:
              g_value_init (out_gvalue, G_TYPE_STRV);
              array = g_variant_dup_bytestring_array (value, NULL);
              g_value_take_boxed (out_gvalue, array);
              break;

            default:
              g_value_init (out_gvalue, G_TYPE_VARIANT);
              g_value_set_variant (out_gvalue, value);
              break;
            }
          break;

        default:
          g_value_init (out_gvalue, G_TYPE_VARIANT);
          g_value_set_variant (out_gvalue, value);
          break;
        }
      break;

    case G_VARIANT_CLASS_HANDLE:
    case G_VARIANT_CLASS_VARIANT:
    case G_VARIANT_CLASS_MAYBE:
    case G_VARIANT_CLASS_TUPLE:
    case G_VARIANT_CLASS_DICT_ENTRY:
      g_value_init (out_gvalue, G_TYPE_VARIANT);
      g_value_set_variant (out_gvalue, value);
      break;
    }
}