static void ListExtraVideoDirectories(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
  {
    int replyCode = 500;
    cString replyMessage = "Missing extra-video-directories patch";
    cStringList dirs;
#ifdef EXTRA_VIDEO_DIRECTORIES_PATCH
    if (!LockExtraVideoDirectories(false)) {
       replyCode = 550;
       replyMessage = "Unable to lock extra video directory list";
       }
    else {
       if (ExtraVideoDirectories.Size() == 0) {
          replyCode = 550;
          replyMessage = "no extra video directories in list";
          }
       else {
          replyCode = 250;
          replyMessage = "";
          for (int i = 0; i < ExtraVideoDirectories.Size(); i++)
              dirs.Append(strdup(ExtraVideoDirectories.At(i)));
          }
       UnlockExtraVideoDirectories();
       }
#endif
    GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(isas)"));
    g_variant_builder_add(builder, "i", replyCode);
    g_variant_builder_add(builder, "s", *replyMessage);
    GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("as"));
    for (int i = 0; i < dirs.Size(); i++)
        g_variant_builder_add(array, "s", dirs.At(i));
    g_variant_builder_add_value(builder, g_variant_builder_end(array));
    g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
    g_variant_builder_unref(array);
    g_variant_builder_unref(builder);
  };
static gboolean
emit_notifications_in_idle (gpointer user_data)
{
  GObject *object = G_OBJECT (user_data);
  GDBusConnection *connection;
  const gchar *path;
  GHashTable *notification_queue;
  GHashTableIter iter;
  const gchar *property_name;
  GVariant *value;
  GVariantBuilder *builder;
  GVariantBuilder *invalidated_builder;
  GHashTable *pvc;
  gboolean has_changes;

  notification_queue = g_object_get_data (object, "gdbus-codegen-notification-queue");
  path = g_object_get_data (object, "gdbus-codegen-path");
  connection = g_object_get_data (object, "gdbus-codegen-connection");
  pvc = g_object_get_data (object, "gdbus-codegen-pvc");
  g_assert (notification_queue != NULL && path != NULL && connection != NULL && pvc != NULL);

  builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
  invalidated_builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
  g_hash_table_iter_init (&iter, notification_queue);
  has_changes = FALSE;
  while (g_hash_table_iter_next (&iter, (gpointer) &property_name, (gpointer) &value))
    {
      GVariant *cached_value;
      cached_value = g_hash_table_lookup (pvc, property_name);
      if (cached_value == NULL || !g_variant_equal (cached_value, value))
	{
	  g_hash_table_insert (pvc, (gpointer) property_name, (gpointer) g_variant_ref (value));
          g_variant_builder_add (builder, "{sv}", property_name, value);
	  has_changes = TRUE;
	}
    }

  if (has_changes)
    {
      g_dbus_connection_emit_signal (connection,
				     NULL,
				     path,
                                     "org.freedesktop.DBus.Properties",
                                     "PropertiesChanged",
                                     g_variant_new ("(sa{sv}as)",
                                                    "org.gnome.evolution.dataserver.CalendarFactory",
						    builder,
						    invalidated_builder),
				     NULL);
    }
  else
    {
      g_variant_builder_unref (builder);
      g_variant_builder_unref (invalidated_builder);
    }

  g_hash_table_remove_all (notification_queue);
  g_object_set_data (object, "gdbus-codegen-notification-idle-id", GUINT_TO_POINTER (0));
  return FALSE;
}
  static void List(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
  {
    if (g_strcmp0(g_dbus_method_invocation_get_interface_name(Invocation), DBUS_VDR_PLUGIN_INTERFACE) == 0)
       esyslog("dbus2vdr: use of deprecated interface: 'List' should be called with the interface '%s'!", DBUS_VDR_PLUGINMANAGER_INTERFACE);

#define EMPTY(s) (s == NULL ? "" : s)
    GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("a(ss)"));
    int index = 0;
    do
    {
      cPlugin *plugin = cPluginManager::GetPlugin(index);
      if (plugin == NULL)
         break;
      const char *name = plugin->Name();
      const char *version = plugin->Version();
      g_variant_builder_add(array, "(ss)", EMPTY(name), EMPTY(version));
      index++;
    } while (true);
#undef EMPTY

    GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(a(ss))"));
    g_variant_builder_add_value(builder, g_variant_builder_end(array));
    g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
    g_variant_builder_unref(array);
    g_variant_builder_unref(builder);
  }
Exemple #4
0
static int create_func(void *data)
{
	struct gt_gadget_create_data *dt;
	int i;

	GVariantBuilder *b;
	GVariant *gattrs;
	GVariant *gstrs;
	GVariant *v;
	GError *err = NULL;

	dt = (struct gt_gadget_create_data *)data;

	b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
	for (i = USBG_GADGET_ATTR_MIN; i < USBG_GADGET_ATTR_MAX; i++) {
		if (dt->attr_val[i] == -1)
			continue;

		g_variant_builder_add(b, "{sv}",
				      usbg_get_gadget_attr_str(i),
				      g_variant_new(attr_type_get(i), dt->attr_val[i]));
	}
	gattrs = g_variant_builder_end(b);

	b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
	for (i = 0; i < GT_GADGET_STRS_COUNT; i++) {
		if (dt->str_val[i] == NULL)
			continue;

		g_variant_builder_add(b, "{sv}",
				      gadget_strs[i].name,
				      g_variant_new("s", dt->str_val[i]));
	}
	gstrs = g_variant_builder_end(b);

	v = g_dbus_connection_call_sync(backend_ctx.gadgetd_conn,
					"org.usb.gadgetd",
					"/org/usb/Gadget",
					"org.usb.device.GadgetManager",
					"CreateGadget",
					g_variant_new("(s@a{sv}@a{sv})",
						      dt->name,
						      gattrs,
						      gstrs),
					NULL,
					G_DBUS_CALL_FLAGS_NONE,
					-1,
					NULL,
					&err);

	if (err) {
		fprintf(stderr, "Unable to create gadget: %s\n", err->message);
		return -1;
	}

	g_variant_unref(v);
	return 0;
}
 static void ListSkins(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
 {
   GVariantBuilder *ret = g_variant_builder_new(G_VARIANT_TYPE("(ia(iss))"));
   g_variant_builder_add(ret, "i", 900);
   GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("a(iss)"));
   for (cSkin* skin = Skins.First(); skin; skin = Skins.Next(skin))
       g_variant_builder_add_value(array, BuildSkin(skin));
   g_variant_builder_add_value(ret, g_variant_builder_end(array));
   g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(ret));
   g_variant_builder_unref(array);
   g_variant_builder_unref(ret);
 };
Exemple #6
0
static void
emit_property_changes(XmrMprisPlugin *plugin, GHashTable *changes, const char *interface)
{
	GError *error = NULL;
	GVariantBuilder *properties;
	GVariantBuilder *invalidated;
	GVariant *parameters;
	gpointer propname, propvalue;
	GHashTableIter iter;

	/* build property changes */
	properties = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
	invalidated = g_variant_builder_new(G_VARIANT_TYPE ("as"));
	g_hash_table_iter_init(&iter, changes);
	while (g_hash_table_iter_next(&iter, &propname, &propvalue))
	{
		if (propvalue != NULL)
		{
			g_variant_builder_add(properties,
					       "{sv}",
					       propname,
					       propvalue);
		}
		else
		{
			g_variant_builder_add(invalidated, "s", propname);
		}

	}

	parameters = g_variant_new("(sa{sv}as)",
				    interface,
				    properties,
				    invalidated);
	g_variant_builder_unref(properties);
	g_variant_builder_unref(invalidated);
	g_dbus_connection_emit_signal(plugin->connection,
				       NULL,
				       MPRIS_OBJECT_NAME,
				       "org.freedesktop.DBus.Properties",
				       "PropertiesChanged",
				       parameters,
				       &error);
	if (error != NULL)
	{
		g_warning("Unable to send MPRIS property changes for %s: %s",
			   interface, error->message);
		g_clear_error(&error);
	}
}
 static void sReturnError(GDBusMethodInvocation *Invocation, int  ReplyCode, const char *ReplyMessage)
 {
   GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(isaa(sv))"));
   g_variant_builder_add(builder, "i", ReplyCode);
   g_variant_builder_add(builder, "s", ReplyMessage);
   GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("aa(sv)"));
   GVariantBuilder *innerArray = g_variant_builder_new(G_VARIANT_TYPE("a(sv)"));
   g_variant_builder_add_value(array, g_variant_builder_end(innerArray));
   g_variant_builder_add_value(builder, g_variant_builder_end(array));
   g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
   g_variant_builder_unref(innerArray);
   g_variant_builder_unref(array);
   g_variant_builder_unref(builder);
 };
void  cDBusHelper::AddKeyValue(GVariantBuilder *Array, const char *Key, const gchar *Type, void **Value)
{
  GVariantBuilder *element = g_variant_builder_new(G_VARIANT_TYPE("(sv)"));

  g_variant_builder_add(element, "s", Key);

  GVariantBuilder *variant = g_variant_builder_new(G_VARIANT_TYPE("v"));
  g_variant_builder_add(variant, Type, *Value);
  g_variant_builder_add_value(element, g_variant_builder_end(variant));

  g_variant_builder_add_value(Array, g_variant_builder_end(element));

  g_variant_builder_unref(variant);
  g_variant_builder_unref(element);
}
Exemple #9
0
static void
test_data_init (TestData *td)
{
  GError *local_error = NULL;
  GError **error = &local_error;
  g_autofree char *http_address = NULL;
  g_autofree char *repo_url = NULL;

  td->repo = ot_test_setup_repo (NULL, error);
  if (!td->repo)
    goto out;

  if (!ot_test_run_libtest ("setup_fake_remote_repo1 archive-z2", error))
    goto out;

  if (!g_file_get_contents ("httpd-address", &http_address, NULL, error))
    goto out;

  repo_url = g_strconcat (http_address, "/ostree/gnomerepo", NULL);

  { g_autoptr(GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
    g_autoptr(GVariant) opts = NULL;

    g_variant_builder_add (builder, "{s@v}", "gpg-verify", g_variant_new_variant (g_variant_new_boolean (FALSE)));
    opts = g_variant_ref_sink (g_variant_builder_end (builder));

    if (!ostree_repo_remote_change (td->repo, NULL, OSTREE_REPO_REMOTE_CHANGE_ADD,
                                    "origin", repo_url, opts, NULL, error))
      goto out;
  }

 out:
  g_assert_no_error (local_error);
}
Exemple #10
0
static void
do_refresh (NAApplication *application)
{
  struct timeval t;
  gettimeofday (&t, NULL);
  GList *proc_info = na_process_info_get_all (t);

  if (proc_info == NULL)
    return;

  GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
  while (proc_info != NULL)
    {
      NAProcInfo *info = (NAProcInfo *)proc_info->data;
      g_variant_builder_add (builder, "(sidd)", info->name, info->pid, tokbps (info->recv), tokbps (info->sent));
      proc_info = proc_info->next;
    }

  g_debug ("DBUS: Emitting signal on system bus");
  g_dbus_connection_emit_signal (na_application_get_system_bus (application),
                                 NULL,
                                 NETWORK_ANALYZER_DBUS_OBJECT_PATH,
                                 NETWORK_ANALYZER_DBUS_IFACE,
                                 "UsageChanged",
                                 g_variant_new ("(a(sidd))", builder),
                                 NULL);

  g_variant_builder_unref (builder);
}
Exemple #11
0
/**
 * send_properites_changed
 **/
static void
emit_properites_changed (UrfKillswitch *killswitch)
{
	UrfKillswitchPrivate *priv = killswitch->priv;
	GVariantBuilder *builder;
	GError *error = NULL;

	builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
	g_variant_builder_add (builder,
	                       "{sv}",
	                       "state",
	                       g_variant_new_int32 (priv->state));

	g_dbus_connection_emit_signal (priv->connection,
	                               NULL,
	                               priv->object_path,
	                               "org.freedesktop.DBus.Properties",
	                               "PropertiesChanged",
	                               g_variant_new ("(sa{sv}as)",
	                                              URF_KILLSWITCH_INTERFACE,
	                                              builder,
	                                              NULL),
	                                &error);
	if (error) {
		g_warning ("Failed to emit PropertiesChanged: %s", error->message);
		g_error_free (error);
	}
}
Exemple #12
0
GVariant *
_secret_session_encode_secret (SecretSession *session,
                               SecretValue *value)
{
	GVariantBuilder *builder;
	GVariant *result = NULL;
	GVariantType *type;
	gboolean ret;

	g_return_val_if_fail (session != NULL, NULL);
	g_return_val_if_fail (value != NULL, NULL);

	type = g_variant_type_new ("(oayays)");
	builder = g_variant_builder_new (type);

#ifdef WITH_GCRYPT
	if (session->key)
		ret = service_encode_aes_secret (session, value, builder);
	else
#endif
		ret = service_encode_plain_secret (session, value, builder);
	if (ret)
		result = g_variant_builder_end (builder);

	g_variant_builder_unref (builder);
	g_variant_type_free (type);
	return result;
}
Exemple #13
0
static gboolean
ol_config_proxy_set_default (OlConfigProxy *config,
                             const gchar *key,
                             GVariant *value)
{
  ol_assert_ret (key != NULL && key[0] != '\0', FALSE);
  OlConfigProxyPrivate *priv = OL_CONFIG_PROXY_GET_PRIVATE (config);
  if (key[0] == '.' && !g_hash_table_lookup (priv->temp_values, key))
  {
    g_variant_ref_sink (value);
    g_hash_table_insert (priv->temp_values,
                         g_strdup (key),
                         g_variant_new ("(*)", g_variant_ref_sink (value)));
    g_signal_emit (config,
                   _signals[SIGNAL_CHANGED],
                   g_quark_from_string (key),
                   key);
    g_variant_unref (value);
  }
  else
  {
    if (priv->default_builder == NULL)
    {
      priv->default_builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
      priv->default_sync_handler = g_timeout_add (DEFAULT_SYNC_TIMEOUT,
                                                  (GSourceFunc) _sync_default_cb,
                                                  config);
    }
    g_variant_builder_add (priv->default_builder, "{sv}", key, value);
  }
  return TRUE;
}
Exemple #14
0
static gboolean handle_set_property (GDBusConnection *connection,
				     const gchar *sender,
				     const gchar *object_path,
				     const gchar *interface_name,
				     const gchar *property_name,
				     GVariant *value,
				     GError **error,
				     gpointer user_data)
{
	printf("set property: '%s'\n", property_name);
	if (!g_strcmp0(property_name, "Title")) {
		if (g_strcmp0(_global_title, g_variant_get_string (value, NULL))) {
			GVariantBuilder *builder;
			GError *local_error;
			g_free(_global_title);
			_global_title = g_variant_dup_string(value, NULL);

			local_error = NULL;
			builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
			g_variant_builder_add
				(builder, "{sv}", "Title",
				 g_variant_new_string(_global_title));
			g_dbus_connection_emit_signal
				(connection, NULL, object_path,
				 "org.freedesktop.DBus.Properties",
				 "PropertiesChanged",
				 g_variant_new("(sa{sv}as)", interface_name,
					       builder, NULL),
				 &local_error);
			g_assert_no_error (local_error);
		}
	}

	return *error == NULL;
}
gboolean connman_service_set_ipv4(connman_service_t *service, ipv4info_t *ipv4)
{
	if(NULL == service || NULL == ipv4)
		return FALSE;

	GVariantBuilder *ipv4_b;
	GVariant *ipv4_v;

	ipv4_b = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
	if(NULL != ipv4->method)
		g_variant_builder_add (ipv4_b, "{sv}", "Method", g_variant_new_string(ipv4->method));
	if(NULL != ipv4->address)
		g_variant_builder_add (ipv4_b, "{sv}", "Address", g_variant_new_string(ipv4->address));
	if(NULL != ipv4->netmask)
		g_variant_builder_add (ipv4_b, "{sv}", "Netmask", g_variant_new_string(ipv4->netmask));
	if(NULL != ipv4->gateway)
		g_variant_builder_add (ipv4_b, "{sv}", "Gateway", g_variant_new_string(ipv4->gateway));
	ipv4_v = g_variant_builder_end (ipv4_b);

	GError *error = NULL;

	connman_interface_service_call_set_property_sync(service->remote, "IPv4.Configuration", g_variant_new_variant(ipv4_v), NULL, &error);
	if (error)
	{
		WCA_LOG_CRITICAL("Error: %s", error->message);
		g_error_free(error);
		return FALSE;
	}
	return TRUE;
}
/**
 * autolink_emitsig_recvmcuinfo - recv mcu info frome uart, 
 *                                and emit signal mcuinfo to other process
 *
 * @pmcu_info  : mcu info
 *
 * returns:
 *     TRUE
 */
extern gboolean
autolink_emitsig_recvmcuinfo (const autolink_mcu_info_dbus_ptr pmcu_info)
{
  GVariantBuilder *builder;
  GVariant *value;
  guchar *pos;
  int i;

  if (pmcu_info == NULL) return FALSE;

  DBG_LOG ("emit signal mcuinfo, info type: %d.\n", pmcu_info->mcu_info_type);

  pos = pmcu_info;

  builder = g_variant_builder_new (G_VARIANT_TYPE ("ay"));

  for (i = 0; i < MCUINFO_LEN; i++) {
    g_variant_builder_add (builder, "y", *pos);
    pos++;
  }

  value = g_variant_new ("(ay)", builder);
  g_variant_builder_unref (builder);

  gdbus_mcuinfo_emit_recv_mcuinfo(pSkeleton, value);

  return TRUE;
}
Exemple #17
0
/* Controller1 interface callbacks */
static gboolean
korva_server_on_handle_get_devices (KorvaController1      *iface,
                                    GDBusMethodInvocation *invocation,
                                    gpointer               user_data)
{
    KorvaServer *self = KORVA_SERVER (user_data);
    GVariantBuilder *builder;
    GVariant *result;
    GList *it;
    gboolean devices = FALSE;

    korva_server_reset_timeout (self);

    builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
    it = self->priv->backends;
    while (it) {
        KorvaBackend *backend = (KorvaBackend *) it->data;
        if (korva_device_lister_get_device_count (backend->lister) > 0) {
            devices = TRUE;
            serialize_device_list_backend (backend, builder);
        }
        it = it->next;
    }

    /* Add empty hash if no devices found */
    if (!devices) {
        g_variant_builder_add_value (builder, g_variant_new ("a{sv}", NULL));
    }

    result = g_variant_builder_end (builder);

    korva_controller1_complete_get_devices (iface, invocation, result);

    return TRUE;
}
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);
}
Exemple #19
0
void
on_interpreter_cell_changed(GtkCellRendererCombo *combo, char *path_string, GtkTreeIter *new_iter, ChimaraGlk *glk)
{
	unsigned int format, interpreter;
	format = (unsigned int)strtol(path_string, NULL, 10);
	GtkTreeModel *combo_model;
	g_object_get(combo, "model", &combo_model, NULL);
	char *combo_string = gtk_tree_model_get_string_from_iter(combo_model, new_iter);
	interpreter = (unsigned int)strtol(combo_string, NULL, 10);
	g_free(combo_string);

	chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), format, interpreter);

	/* Display the new setting in the list */
	GtkTreeIter iter;
	GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
	gtk_tree_model_get_iter(GTK_TREE_MODEL(preferred_list), &iter, path);
	gtk_tree_path_free(path);
	gtk_list_store_set(preferred_list, &iter,
		1, interpreter_to_display_string(interpreter),
		-1);

	/* Save the new settings in the preferences file */
	extern GSettings *prefs_settings;
	GVariantBuilder *builder = g_variant_builder_new( G_VARIANT_TYPE("a{ss}") );
	unsigned int count;
	for(count = 0; count < CHIMARA_IF_NUM_FORMATS; count++) {
		g_variant_builder_add(builder, "{ss}",
			format_to_string(count),
			interpreter_to_string(chimara_if_get_preferred_interpreter(CHIMARA_IF(glk), count)));
	}
	g_settings_set(prefs_settings, "preferred-interpreters", "a{ss}", builder);
	g_variant_builder_unref(builder);
}
/**
* rpmostree_load_sysroot
* @sysroot: sysroot path
* @force_peer: Force a peer connection
* @cancellable: A GCancellable
* @out_sysroot: (out) Return location for sysroot
* @error: A pointer to a GError pointer.
*
* Returns: True on success
**/
gboolean
rpmostree_load_sysroot (gchar *sysroot,
                        gboolean force_peer,
                        GCancellable *cancellable,
                        RPMOSTreeSysroot **out_sysroot_proxy,
                        GPid *out_peer_pid,
                        GError **error)
{
  const char *bus_name = NULL;
  glnx_unref_object GDBusConnection *connection = NULL;
  glnx_unref_object RPMOSTreeSysroot *sysroot_proxy = NULL;
  g_autoptr(GVariantBuilder) options_builder =
    g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
  _cleanup_peer_ GPid peer_pid = 0;

  connection = get_connection_for_path (sysroot, force_peer, &peer_pid,
                                        cancellable, error);
  if (connection == NULL)
    return FALSE;

  if (g_dbus_connection_get_unique_name (connection) != NULL)
    bus_name = BUS_NAME;

  sysroot_proxy = rpmostree_sysroot_proxy_new_sync (connection,
                                                    G_DBUS_PROXY_FLAGS_NONE,
                                                    bus_name,
                                                    "/org/projectatomic/rpmostree1/Sysroot",
                                                    NULL,
                                                    error);
  if (sysroot_proxy == NULL)
    return FALSE;

  /* Try to register if we can; it doesn't matter much now since the daemon doesn't
   * auto-exit, though that might change in the future. But only register if we're active or
   * root; the daemon won't allow it otherwise. */
  uid_t uid = getuid ();
  gboolean should_register;
  if (uid == 0)
    should_register = TRUE;
  else
    {
      g_autofree char *state = NULL;
      if (sd_uid_get_state (uid, &state) >= 0)
        should_register = (g_strcmp0 (state, "active") == 0);
      else
        should_register = FALSE;
    }

  if (should_register)
    {
      if (!rpmostree_sysroot_call_register_client_sync (sysroot_proxy,
                                                        g_variant_builder_end (options_builder),
                                                        cancellable, error))
        return FALSE;
    }

  *out_sysroot_proxy = g_steal_pointer (&sysroot_proxy);
  *out_peer_pid = peer_pid; peer_pid = 0;
  return TRUE;
}
/**
 * EscalateModuleStart:
 * @self: PAM module being described in the start message.
 * @action: Action being called on this module, like
 * #ESCALATE_MESSAGE_ACTION_AUTHENTICATE when pam_sm_authenticate() is being
 * used.
 * @error: (out)(allow-none): Error return location or #NULL.
 *
 * Returns: #TRUE if the message was sent.
 */
gboolean EscalateModuleStart(EscalateModule *self, EscalateMessageAction action,
                             GError **error) {
  GVariantBuilder *items = NULL;
  EscalateMessage *message = NULL;
  gboolean result = FALSE;

  items = g_variant_builder_new(G_VARIANT_TYPE("a{ims}"));
  for (guint i = 0; i < G_N_ELEMENTS(escalate_module_include_items); i++) {
    gint item = escalate_module_include_items[i];
    if (!EscalateModuleStartAddItem(self, items, item, error)) {
      goto done;
    }
  }

  // TODO(vonhollen): Include environment variables?
  message = EscalateMessageNew(ESCALATE_MESSAGE_TYPE_START, action, self->flags,
                               self->username, items);
  if (EscalateSubprocessSend(self->child, message, error))
    result = TRUE;

done:
  if (message)
    EscalateMessageUnref(message);
  g_variant_builder_unref(items);
  return result;
}
static void hev_dbus_object_test_notify_value_handler(GObject *obj,
			GParamSpec *pspec, gpointer user_data)
{
	HevDBusInterfaceTest *self = HEV_DBUS_INTERFACE_TEST(user_data);
	HevDBusInterfaceTestPrivate *priv = HEV_DBUS_INTERFACE_TEST_GET_PRIVATE(self);
	GDBusConnection *connection = NULL;
	const gchar *object_path = NULL;
	GVariantBuilder *builder = NULL;
	GVariant *variant = NULL;
	gchar *p = NULL;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	connection = g_dbus_interface_skeleton_get_connection(G_DBUS_INTERFACE_SKELETON(self));
	object_path = g_dbus_interface_skeleton_get_object_path(G_DBUS_INTERFACE_SKELETON(self));

	builder = g_variant_builder_new(G_VARIANT_TYPE_VARDICT);
	g_object_get(obj, "value", &p, NULL);
	g_variant_builder_add(builder, "{sv}", "Value", g_variant_new_string(p));
	variant = g_variant_builder_end(builder);
	g_variant_builder_unref(builder);
	variant = g_variant_new("(@a{sv})", variant);
	g_free(p);

	g_dbus_connection_emit_signal(connection, NULL, object_path,
				"org.freedesktop.DBus.Properties", "PropertiesChanged",
				variant, NULL);

	g_variant_unref(variant);
}
EXPORT_API int tel_req_sap_transfer_apdu(TapiHandle *handle, TelSapApduData_t *apdu_data, tapi_response_cb callback, void *user_data)
{
	struct tapi_resp_data *evt_cb_data = NULL;
	GVariantBuilder *builder = NULL;
	GVariant *param = NULL;
	GVariant *inner_gv = NULL;
	int i = 0;

	dbg("Func Entrance");
	TAPI_RETURN_VAL_IF_FAIL(apdu_data, TAPI_API_INVALID_PTR);

	MAKE_RESP_CB_DATA(evt_cb_data, handle, callback, user_data);

	builder = g_variant_builder_new(G_VARIANT_TYPE ("ay"));
	for (i = 0; i < apdu_data->apdu_len; i++) {
		dbg("apdu_data->apdu_data[%d][0x%02x]", i,apdu_data->apdu_data[i]);
		g_variant_builder_add(builder, "y", apdu_data->apdu_data[i]);
	}
	inner_gv = g_variant_builder_end(builder);
	param = g_variant_new("(v)", inner_gv);
	/*g_variant_builder_unref (builder);*/

	g_dbus_connection_call(handle->dbus_connection, DBUS_TELEPHONY_SERVICE, handle->path,
			DBUS_TELEPHONY_SAP_INTERFACE, "TransferAPDU", param, NULL, G_DBUS_CALL_FLAGS_NONE, -1,
			NULL, on_response_sap_transfer_apdu, evt_cb_data);

	return TAPI_API_SUCCESS;
}
static void
query_cb (GObject      *const object,
          GAsyncResult *const result,
          GTask        *const task)
{

  g_autoptr(GError) error = NULL;

  g_autoptr(TrackerSparqlCursor) cursor = nul_sparql_query_util_query_finish (
    result,
    &error
  );

  if (error) {
    nul_error ("failed to execute query: %s", error->message);
  }

  AsyncSparqlWork *const work = async_sparql_work_get (task);
  work->cursor = g_object_ref_sink (cursor);
  work->builder = g_variant_builder_new (VARDICT_ARRAY);

  tracker_sparql_cursor_next_async (
    cursor,
    g_task_get_cancellable (task),
    (GAsyncReadyCallback) next_cb,
    task
  );

}
/**
 * EscalateUtilPamEnvToVariant:
 * @pamh: PAM handle with environment variables to serialize.
 * @error: (out)(allow-none): Error return location or #NULL.
 *
 * Returns: New GVariantBuilder with a map of environment key to value strings,
 * or #NULL if there was an error getting the values.
 */
GVariantBuilder *EscalateUtilPamEnvToVariant(pam_handle_t *pamh,
                                             GError **error) {
  char **env_list = NULL;
  GVariantBuilder *builder = NULL;

  env_list = pam_getenvlist(pamh);
  if (!env_list) {
    g_set_error(error, ESCALATE_UTIL_ERROR, ESCALATE_UTIL_ERROR_ENVIRONMENT,
                "Failed to fetch PAM environment list.");
    return NULL;
  }

  builder = g_variant_builder_new(G_VARIANT_TYPE("a{ss}"));
  for (guint i = 0; builder && env_list[i]; i++) {
    gchar **parts = g_strsplit(env_list[i], "=", 2);
    if (parts[0] && parts[1] && strlen(parts[0]) > 0) {
      g_variant_builder_add(builder, "{ss}", parts[0], parts[1]);
    } else {
      g_set_error(error, ESCALATE_UTIL_ERROR, ESCALATE_UTIL_ERROR_ENVIRONMENT,
                  "Failed to parse environment variable '%s'", env_list[i]);
      g_variant_builder_unref(builder);
      builder = NULL;
    }
    g_strfreev(parts);
  }

  for (guint i = 0; env_list[i]; i++) {
    free(env_list[i]);
  }
  free(env_list);

  return builder;
}
/*
** DBus method call: "CrownChallenge"
*/
gboolean on_handle_crown_challenge ( Warfacebot *object,
									 GDBusMethodInvocation *invocation )
{
	if ( invalidated )
	{
		struct list *ml = session.wf.missions;

		GVariantBuilder *marr_builder;

		if ( marr != NULL )
			g_variant_unref ( marr );

		marr_builder = g_variant_builder_new ( G_VARIANT_TYPE ( "a(sssii)" ) );

		list_foreach ( ml, (f_list_callback) mlist_to_array, marr_builder );

		marr = g_variant_new ( "a(sssii)", marr_builder );

		g_variant_ref ( marr );

		g_variant_builder_unref ( marr_builder );

		invalidated = FALSE;
	}

	warfacebot_complete_crown_challenge ( object, invocation, marr );

	return TRUE;
}
 static void CurrentSkin(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
 {
   GVariantBuilder *ret = g_variant_builder_new(G_VARIANT_TYPE("(i(iss))"));
   g_variant_builder_add(ret, "i", 900);
   g_variant_builder_add_value(ret, BuildSkin(Skins.Current()));
   g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(ret));
   g_variant_builder_unref(ret);
 };
void  cDBusHelper::SendReply(GDBusMethodInvocation *Invocation, int  ReplyCode, const char *ReplyMessage)
{
  GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(is)"));
  g_variant_builder_add(builder, "i", ReplyCode);
  g_variant_builder_add(builder, "s", ReplyMessage);
  g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
  g_variant_builder_unref(builder);
}
Exemple #29
0
static void
test_g_variant_builder (void)
{
  g_autoptr(GVariantBuilder) val = g_variant_builder_new (G_VARIANT_TYPE ("as"));
  g_auto(GVariantBuilder) stackval;

  g_assert (val != NULL);
  g_variant_builder_init (&stackval, G_VARIANT_TYPE ("as"));
}
Exemple #30
0
void cDBusUpstart::EmitPluginEvent(cDBusConnection *Connection, const char *Action)
{
  if ((Connection == NULL) || (Action == NULL) || (*Action == 0))
     return;
  GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(sasb)"));
  g_variant_builder_add(builder, "s", "vdr-plugin");
  GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("as"));
  cPlugin *plugin;
  for (int i = 0; (plugin = cPluginManager::GetPlugin(i)) != NULL; i++)
      g_variant_builder_add(array, "s", *cString::sprintf("%s=%s", plugin->Name(), Action));
  g_variant_builder_add_value(builder, g_variant_builder_end(array));
  g_variant_builder_add(builder, "b", FALSE);

  Connection->CallMethod(new cDBusMethodCall("com.ubuntu.Upstart", "/com/ubuntu/Upstart", "com.ubuntu.Upstart0_6", "EmitEvent", g_variant_builder_end(builder), OnUpstartReply, NULL));

  g_variant_builder_unref(array);
  g_variant_builder_unref(builder);
}