static void
screensaver_inhibit_dbus (ScreenSaver * screensaver, gboolean inhibit)
{
  if (!screensaver->gs_proxy)
    return;

  if (inhibit) {
    guint xid;

    xid = screensaver->window;

    g_dbus_proxy_call (screensaver->gs_proxy,
        "Inhibit",
        g_variant_new ("(susu)",
            g_get_application_name (),
            xid,
            REASON,
            GS_NO_IDLE_FLAG),
        G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, on_inhibit_cb, screensaver);
  } else {
    if (screensaver->cookie > 0) {
      g_dbus_proxy_call (screensaver->gs_proxy,
          "Uninhibit",
          g_variant_new ("(u)", screensaver->cookie),
          G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, on_uninhibit_cb,
          screensaver);
    }
  }
}
static void
_parent_init_async_cb (GObject      *obj,
                       GAsyncResult *res,
                       gpointer      user_data)
{
    InitData *data;

    data = (InitData*)user_data;

    /* start our own initialization */
    g_dbus_proxy_call (G_DBUS_PROXY (obj),
                       "GetProperties",
                       NULL,
                       G_DBUS_CALL_FLAGS_NONE,
                       -1,
                       data->cancellable,
                       _get_properties_cb,
                       data);

    g_dbus_proxy_call (G_DBUS_PROXY (obj),
                       "GetServices",
                       NULL,
                       G_DBUS_CALL_FLAGS_NONE,
                       -1,
                       data->cancellable,
                       _get_services_cb,
                       data);

    g_signal_connect (obj, "notify::g-name-owner",
                      G_CALLBACK (_name_owner_notify_cb), NULL);
}
Exemple #3
0
/**
 * fcitx_client_set_surrounding_text:
 * @self: A #FcitxClient
 * @text: (transfer none) (allow-none): surroundng text
 * @cursor: cursor position coresponding to text
 * @anchor: anchor position coresponding to text
 **/
FCITX_EXPORT_API
void fcitx_client_set_surrounding_text(FcitxClient* self, gchar* text, guint cursor, guint anchor)
{
    if (self->priv->icproxy) {
        if (text) {
            g_dbus_proxy_call(self->priv->icproxy, "SetSurroundingText", g_variant_new("(suu)", text, cursor, anchor), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
        }
        else {
            g_dbus_proxy_call(self->priv->icproxy, "SetSurroundingTextPosition", g_variant_new("(uu)", cursor, anchor), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
        }
    }
}
static void
copy_settings (GtkButton *button, GtkBuilder *dialog)
{
        const gchar *language;
        const gchar *region;
        const gchar *layout;
        const gchar *variants;
        GtkWidget *label;
        GVariantBuilder *b;
        gchar *s;

        label = WID ("user_display_language");
        language = g_object_get_data (G_OBJECT (label), "language");
        label = WID ("user_format");
        region = g_object_get_data (G_OBJECT (label), "region");

        b = g_variant_builder_new (G_VARIANT_TYPE ("as"));
        s = g_strconcat ("LANG=", language, NULL);
        g_variant_builder_add (b, "s", s);
        g_free (s);
        if (g_strcmp0 (language, region) != 0) {
                s = g_strconcat ("LC_TIME=", region, NULL);
                g_variant_builder_add (b, "s", s);
                g_free (s);
                s = g_strconcat ("LC_NUMERIC=", region, NULL);
                g_variant_builder_add (b, "s", s);
                g_free (s);
                s = g_strconcat ("LC_MONETARY=", region, NULL);
                g_variant_builder_add (b, "s", s);
                g_free (s);
                s = g_strconcat ("LC_MEASUREMENT=", region, NULL);
                g_variant_builder_add (b, "s", s);
                g_free (s);
        }

        g_dbus_proxy_call (localed_proxy,
                           "SetLocale",
                           g_variant_new ("(asb)", b, TRUE),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1, NULL, NULL, NULL);
        g_variant_builder_unref (b);

        label = WID ("user_input_source");
        layout = g_object_get_data (G_OBJECT (label), "input_source");
        variants = g_object_get_data (G_OBJECT (label), "input_variants");

        g_dbus_proxy_call (localed_proxy,
                           "SetX11Keyboard",
                           g_variant_new ("(ssssbb)", layout, "", variants ? variants : "", "", TRUE, TRUE),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1, NULL, NULL, NULL);
}
Exemple #5
0
/**
 * fcitx_kbd_set_default_layout:
 * @kbd: A #FcitxKbd
 * @layout: layout
 * @variant: variant
 *
 * Set a layout binding with the state when there is no input method
 **/
FCITX_EXPORT_API
void fcitx_kbd_set_default_layout(FcitxKbd *kbd, const gchar *layout,
                                  const gchar *variant) {
    g_dbus_proxy_call(G_DBUS_PROXY(kbd), "SetDefaultLayout",
                      g_variant_new("(ss)", layout, variant),
                      G_DBUS_CALL_FLAGS_NO_AUTO_START, 0, NULL, NULL, NULL);
}
Exemple #6
0
static gboolean
handle_op (CockpitRealms *object,
           GDBusMethodInvocation *invocation,
           const gchar *op,
           const gchar *arg_name,
           GVariant *arg_creds,
           GVariant *arg_options)
{
  Realms *realms = REALMS (object);

  if (!set_invocation (realms, invocation, op, arg_name, arg_creds, arg_options))
    return TRUE;

  GVariantBuilder discover_options;
  g_variant_builder_init (&discover_options, G_VARIANT_TYPE ("a{sv}"));

  copy_option (&discover_options, arg_options, "client-software");
  copy_option (&discover_options, arg_options, "server-software");
  g_variant_builder_add (&discover_options, "{sv}",
                         "operation", g_variant_new_string (realms->op_id));

  g_dbus_proxy_call (realms->realmd,
                     "Discover",
                     g_variant_new ("(sa{sv})", arg_name, &discover_options),
                     G_DBUS_CALL_FLAGS_NONE,
                     G_MAXINT,
                     NULL,
                     on_discover_for_op_done,
                     realms);

  return TRUE;
}
Exemple #7
0
static void
on_dbus_proxy_ready (GObject      *source_object,
                     GAsyncResult *res,
                     gpointer      user_data)
{
        GTask *task = G_TASK (user_data);
        gpointer *info = g_task_get_source_object (task);
        GClueClientInfoPrivate *priv = GCLUE_CLIENT_INFO (info)->priv;
        GError *error = NULL;

        priv->dbus_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
        if (priv->dbus_proxy == NULL) {
                g_task_return_error (task, error);
                g_object_unref (task);
                return;
        }

        g_dbus_proxy_call (priv->dbus_proxy,
                           "GetConnectionUnixUser",
                           g_variant_new ("(s)", priv->bus_name),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
                           g_task_get_cancellable (task),
                           on_get_user_id_ready,
                           task);
}
Exemple #8
0
static void start_auth_check(const gchar *name, const gchar *action, gboolean user_interaction,
			     GDBusMethodInvocation *invocation, auth_check_handler handler,
			     struct method_call_data *handler_data) {
	GVariant *parameters;
	GVariantBuilder builder1, builder2;
	struct auth_check *auth_check;

	auth_check = g_new(struct auth_check, 1);
	auth_check->cancellable = g_cancellable_new();
	auth_check->cancel_id = g_timeout_add(POLKIT_AUTH_CHECK_TIMEOUT * 1000, cancel_auth_check, auth_check);
	auth_check->cancel_string = g_malloc(30);
	auth_check->invocation = invocation;
	auth_check->handler = handler;
	auth_check->handler_data = (struct method_call_data *)g_memdup(handler_data, sizeof *handler_data);

	snprintf(auth_check->cancel_string, 30, "cancel%u", auth_check->cancel_id);

	g_variant_builder_init(&builder1, G_VARIANT_TYPE("a{sv}"));
	g_variant_builder_add(&builder1, "{sv}", "name", g_variant_new_string(name));

	g_variant_builder_init(&builder2, G_VARIANT_TYPE("a{ss}"));

	parameters = g_variant_new("((sa{sv})sa{ss}us)", "system-bus-name", &builder1,
				   action, &builder2, user_interaction ? 1 : 0, auth_check->cancel_string);

	g_dbus_proxy_call(polkit_proxy, "CheckAuthorization", parameters,
			  G_DBUS_CALL_FLAGS_NONE, -1, NULL, finish_auth_check, auth_check);

	running_auth_checks++;
}
Exemple #9
0
FCITX_EXPORT_API
void fcitx_client_reset(FcitxClient* self)
{
    if (self->priv->icproxy) {
        g_dbus_proxy_call(self->priv->icproxy, "Reset", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
    }
}
static void
got_power_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  GError *error = NULL;
  CcScreenPanelPrivate *priv = CC_SCREEN_PANEL (user_data)->priv;

  priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
  if (priv->proxy == NULL)
    {
      g_printerr ("Error creating proxy: %s\n", error->message);
      g_error_free (error);
      return;
    }

  /* we want to change the bar if the user presses brightness buttons */
  g_signal_connect (priv->proxy,
                    "g-signal",
                    G_CALLBACK (on_signal),
                    user_data);

  /* get the initial state */
  g_dbus_proxy_call (priv->proxy,
                     "GetPercentage",
                     NULL,
                     G_DBUS_CALL_FLAGS_NONE,
                     200, /* we don't want to randomly move the bar */
                     priv->cancellable,
                     get_brightness_cb,
                     user_data);
}
static void
consolekit_stop (void)
{
        GError *error = NULL;
        GDBusProxy *proxy;

        /* power down the machine in a safe way */
        proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                               G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
                                               NULL,
                                               CONSOLEKIT_DBUS_NAME,
                                               CONSOLEKIT_DBUS_PATH_MANAGER,
                                               CONSOLEKIT_DBUS_INTERFACE_MANAGER,
                                               NULL, &error);
        if (proxy == NULL) {
                g_warning ("cannot connect to ConsoleKit: %s",
                           error->message);
                g_error_free (error);
                return;
        }
        g_dbus_proxy_call (proxy,
                           "Stop",
                           NULL,
                           G_DBUS_CALL_FLAGS_NONE,
                           -1, NULL,
                           consolekit_stop_cb, NULL);
        g_object_unref (proxy);
}
static void
nemo_proxy_ready_cb (GObject *object,
                         GAsyncResult *res,
                         gpointer _unused)
{
        GDBusProxy *proxy = NULL;
        GError *error = NULL;

        proxy = g_dbus_proxy_new_for_bus_finish (res, &error);

        if (proxy == NULL) {
                g_warning ("Unable to create a proxy object for the Nemo DBus interface: %s",
                           error->message);
                g_error_free (error);

                return;
        }

        g_dbus_proxy_call (proxy,
                           "EmptyTrash",
                           NULL,
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
                           NULL,
                           nemo_empty_trash_cb,
                           NULL);
}
Exemple #13
0
static void
on_menu_toggle_changed(GSimpleAction *action, GVariant *value, gpointer user_data)
{
  WorkraveApplet *applet = WORKRAVE_APPLET(user_data);
  gboolean new_state = g_variant_get_boolean(value);
  int index = lookup_menu_index_by_action(g_action_get_name(G_ACTION(action)));
  if (index == -1)
    {
      return;
    }

  g_simple_action_set_state(action, value);

  GDBusProxy *proxy = workrave_timerbox_control_get_control_proxy(applet->priv->timerbox_control);
  if (proxy != NULL)
    {
      g_dbus_proxy_call(proxy,
                        menu_data[index].dbuscmd,
                        g_variant_new("(b)", new_state),
                        G_DBUS_CALL_FLAGS_NO_AUTO_START,
                        -1,
                        NULL,
                        (GAsyncReadyCallback) dbus_call_finish,
                        &applet);
    }
}
Exemple #14
0
static void
proxy_ready_cb (GObject *source_object,
                GAsyncResult *res,
                gpointer user_data)
{
	UrfDeviceOfono *modem = URF_DEVICE_OFONO (user_data);
	UrfDeviceOfonoPrivate *priv = URF_DEVICE_OFONO_GET_PRIVATE (modem);
	GError *error = NULL;

	priv->proxy = g_dbus_proxy_new_finish (res, &error);

	if (!error) {
		g_cancellable_reset (priv->cancellable);
		g_signal_connect (priv->proxy, "g-signal",
		                  G_CALLBACK (modem_signal_cb), modem);
		g_dbus_proxy_call (priv->proxy,
		                   "GetProperties",
		                   NULL,
		                   G_DBUS_CALL_FLAGS_NONE,
		                   -1,
		                   priv->cancellable,
		                   (GAsyncReadyCallback) get_properties_cb,
		                   modem);
	} else {
		g_warning ("Could not get oFono Modem proxy: %s",
		           error ? error->message : "(unknown error)");
	}
}
Exemple #15
0
/**
 * fu_util_clear_results:
 **/
static gboolean
fu_util_clear_results (FuUtilPrivate *priv, gchar **values, GError **error)
{
	if (g_strv_length (values) != 1) {
		g_set_error_literal (error,
				     FWUPD_ERROR,
				     FWUPD_ERROR_INTERNAL,
				     "Invalid arguments: expected 'id'");
		return FALSE;
	}

	/* clear results, and wait for reply */
	g_dbus_proxy_call (priv->proxy,
			   "ClearResults",
			   g_variant_new ("(s)", values[0]),
			   G_DBUS_CALL_FLAGS_NONE,
			   -1,
			   NULL,
			   fu_util_get_devices_cb, priv);
	g_main_loop_run (priv->loop);
	if (priv->val == NULL) {
		g_dbus_error_strip_remote_error (priv->error);
		g_propagate_error (error, priv->error);
		return FALSE;
	}
	return TRUE;
}
Exemple #16
0
/**
 * fu_util_get_updates_internal:
 **/
static GPtrArray *
fu_util_get_updates_internal (FuUtilPrivate *priv, GError **error)
{
	GVariantIter *iter_device;
	GPtrArray *devices = NULL;
	FuDevice *dev;
	gchar *id;
	_cleanup_variant_iter_free_ GVariantIter *iter = NULL;

	g_dbus_proxy_call (priv->proxy,
			   "GetUpdates",
			   NULL,
			   G_DBUS_CALL_FLAGS_NONE,
			   -1,
			   NULL,
			   fu_util_get_devices_cb, priv);
	g_main_loop_run (priv->loop);
	if (priv->val == NULL) {
		g_propagate_error (error, priv->error);
		return NULL;
	}

	/* parse */
	g_variant_get (priv->val, "(a{sa{sv}})", &iter);
	devices = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
	while (g_variant_iter_next (iter, "{&sa{sv}}", &id, &iter_device)) {
		dev = fu_device_new ();
		fu_device_set_id (dev, id);
		fu_device_set_metadata_from_iter (dev, iter_device);
		g_ptr_array_add (devices, dev);
		g_variant_iter_free (iter_device);
	}
	return devices;
}
void
nm_supplicant_manager_iface_release (NMSupplicantManager *self,
                                     NMSupplicantInterface *iface)
{
	NMSupplicantManagerPrivate *priv;
	const char *ifname, *op;

	g_return_if_fail (NM_IS_SUPPLICANT_MANAGER (self));
	g_return_if_fail (NM_IS_SUPPLICANT_INTERFACE (iface));

	ifname = nm_supplicant_interface_get_ifname (iface);
	g_assert (ifname);

	priv = NM_SUPPLICANT_MANAGER_GET_PRIVATE (self);

	g_return_if_fail (g_hash_table_lookup (priv->ifaces, ifname) == iface);

	/* Ask wpa_supplicant to remove this interface */
	op = nm_supplicant_interface_get_object_path (iface);
	if (priv->running && priv->proxy && op) {
		g_dbus_proxy_call (priv->proxy,
		                   "RemoveInterface",
		                   g_variant_new ("(o)", op),
		                   G_DBUS_CALL_FLAGS_NONE,
		                   3000,
		                   NULL,
		                   NULL,
		                   NULL);
	}

	g_hash_table_remove (priv->ifaces, ifname);
}
Exemple #18
0
static gboolean
handle_list_services (CockpitServices *object,
                      GDBusMethodInvocation *invocation)
{
  Services *services = SERVICES (object);

  if (services->systemd == NULL)
    {
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR, COCKPIT_ERROR_FAILED,
                                             "systemd not running");
      return TRUE;
    }

  ListServicesData *data = g_new0(ListServicesData, 1);
  data->services = services;
  data->invocation = invocation;

  g_dbus_proxy_call (services->systemd,
                     "ListUnits",
                     NULL,
                     G_DBUS_CALL_FLAGS_NONE,
                     G_MAXINT,
                     NULL,
                     on_list_units_done,
                     data);
  return TRUE;
}
Exemple #19
0
static void
on_list_units_done (GObject *object,
                    GAsyncResult *res,
                    gpointer user_data)
{
  ListServicesData *data = user_data;
  GError *error = NULL;

  data->units = g_dbus_proxy_call_finish (G_DBUS_PROXY (object), res, &error);
  if (error)
    {
      end_invocation_take_gerror (data->invocation, error);
      g_free (data);
      return;
    }

  g_dbus_proxy_call (data->services->systemd,
                     "ListUnitFiles",
                     NULL,
                     G_DBUS_CALL_FLAGS_NONE,
                     G_MAXINT,
                     NULL,
                     on_list_files_done,
                     data);
}
static void
got_session_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
	GError *error = NULL;
	GnomeSettingsSession *session = GNOME_SETTINGS_SESSION (user_data);

	/* connect to session */
	session->priv->proxy_session = g_dbus_proxy_new_for_bus_finish (res,
									&error);
	if (session->priv->proxy_session == NULL) {
		g_warning ("cannot connect to %s: %s",
			   session->priv->session_id,
			   error->message);
		g_error_free (error);
		return;
	}

	/* is our session active */
	g_dbus_proxy_call (session->priv->proxy_session,
			   "IsActive",
			   NULL,
			   G_DBUS_CALL_FLAGS_NONE,
			   -1,
			   session->priv->cancellable,
			   is_active_cb,
			   session);
}
static void
on_signal (GDBusProxy *proxy,
           gchar      *sender_name,
           gchar      *signal_name,
           GVariant   *parameters,
           gpointer    user_data)
{
  CcScreenPanel *self = CC_SCREEN_PANEL (user_data);

  if (g_strcmp0 (signal_name, "Changed") == 0)
    {
      /* changed, but ignoring */
      if (self->priv->setting_brightness)
        return;

      /* retrieve the value again from g-s-d */
      g_dbus_proxy_call (self->priv->proxy,
                         "GetPercentage",
                         NULL,
                         G_DBUS_CALL_FLAGS_NONE,
                         200, /* we don't want to randomly move the bar */
                         self->priv->cancellable,
                         get_brightness_cb,
                         user_data);
    }
}
static void
got_manager_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
	GDBusProxy *proxy_manager;
	GError *error = NULL;
	guint32 pid;
	GnomeSettingsSession *session = GNOME_SETTINGS_SESSION (user_data);

	proxy_manager = g_dbus_proxy_new_for_bus_finish (res, &error);
	if (proxy_manager == NULL) {
		g_warning ("cannot connect to ConsoleKit: %s",
			   error->message);
		g_error_free (error);
		return;
	}

	/* get the session we are running in */
	pid = getpid ();
	g_dbus_proxy_call (proxy_manager,
			   "GetSessionForUnixProcess",
			   g_variant_new ("(u)", pid),
			   G_DBUS_CALL_FLAGS_NONE,
			   -1, session->priv->cancellable,
			   got_session_path_cb,
			   session);
	g_object_unref (proxy_manager);
}
static void
set_ap_scan_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
{
	NMSupplicantInterface *self;
	NMSupplicantInterfacePrivate *priv;
	gs_unref_variant GVariant *reply = NULL;
	gs_free_error GError *error = NULL;

	reply = g_dbus_proxy_call_finish (proxy, result, &error);
	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
		return;

	self = NM_SUPPLICANT_INTERFACE (user_data);
	priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);

	if (!reply) {
		g_dbus_error_strip_remote_error (error);
		nm_log_warn (LOGD_SUPPLICANT, "Couldn't send AP scan mode to the supplicant interface: %s.",
		             error->message);
		emit_error_helper (self, error);
		return;
	}

	nm_log_info (LOGD_SUPPLICANT, "Config: set interface ap_scan to %d",
	             nm_supplicant_config_get_ap_scan (priv->cfg));

	g_dbus_proxy_call (priv->iface_proxy,
	                   "AddNetwork",
	                   g_variant_new ("(@a{sv})", nm_supplicant_config_to_variant (priv->cfg)),
	                   G_DBUS_CALL_FLAGS_NONE,
	                   -1,
	                   priv->assoc_cancellable,
	                   (GAsyncReadyCallback) add_network_cb,
	                   self);
}
Exemple #24
0
/**
 * cd_profile_set_property:
 * @profile: a #CdProfile instance.
 * @key: a key name
 * @value: a key value
 * @cancellable: a #GCancellable, or %NULL
 * @callback: the function to run on completion
 * @user_data: the data to pass to @callback
 *
 * Deletes a color device.
 *
 * Since: 0.1.8
 **/
void
cd_profile_set_property (CdProfile *profile,
			 const gchar *key,
			 const gchar *value,
			 GCancellable *cancellable,
			 GAsyncReadyCallback callback,
			 gpointer user_data)
{
	CdProfilePrivate *priv = GET_PRIVATE (profile);
	GTask *task = NULL;

	g_return_if_fail (CD_IS_PROFILE (profile));
	g_return_if_fail (key != NULL);
	g_return_if_fail (value != NULL);
	g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
	g_return_if_fail (priv->proxy != NULL);

	task = g_task_new (profile, cancellable, callback, user_data);
	g_dbus_proxy_call (priv->proxy,
			   "SetProperty",
			   g_variant_new ("(ss)",
			   		  key,
			   		  value),
			   G_DBUS_CALL_FLAGS_NONE,
			   -1,
			   cancellable,
			   cd_profile_set_property_cb,
			   task);
}
Exemple #25
0
FCITX_EXPORT_API
void fcitx_client_set_cursor_rect(FcitxClient* self, int x, int y, int w, int h)
{
    if (self->priv->icproxy) {
        g_dbus_proxy_call(self->priv->icproxy, "SetCursorRect", g_variant_new("(iiii)", x, y, w, h), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
    }
}
void
um_user_manager_cache_user (UmUserManager       *manager,
                            const char          *user_name,
                            GCancellable        *cancellable,
                            GAsyncReadyCallback  done,
                            gpointer             done_data,
                            GDestroyNotify       destroy)
{
        AsyncUserOpData *data;

        data = g_new0 (AsyncUserOpData, 1);
        data->manager = g_object_ref (manager);
        data->user_name = g_strdup (user_name);
        data->callback = done;
        data->data = done_data;
        data->destroy = destroy;

        g_dbus_proxy_call (manager->proxy,
                           "CacheUser",
                           g_variant_new ("(s)", user_name),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
                           cancellable,
                           user_call_done,
                           data);
}
Exemple #27
0
static void
on_get_user_id_ready (GObject      *source_object,
                      GAsyncResult *res,
                      gpointer      user_data)
{
        GTask *task = G_TASK (user_data);
        gpointer *info = g_task_get_source_object (task);
        GClueClientInfoPrivate *priv = GCLUE_CLIENT_INFO (info)->priv;
        GError *error = NULL;
        GVariant *results = NULL;

        results = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
                                            res,
                                            &error);
        if (results == NULL) {
                g_task_return_error (task, error);
                g_object_unref (task);

                return;
        }

        g_assert (g_variant_n_children (results) > 0);
        g_variant_get_child (results, 0, "u", &priv->user_id);
        g_variant_unref (results);

        g_dbus_proxy_call (priv->dbus_proxy,
                           "GetConnectionUnixProcessID",
                           g_variant_new ("(s)", priv->bus_name),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
                           g_task_get_cancellable (task),
                           on_get_pid_ready,
                           task);
}
Exemple #28
0
/**
 * fcitx_kbd_set_layout_for_im:
 * @kbd: A #FcitxKbd
 * @imname: input method name
 * @layout: layout
 * @variant: variant
 *
 * Set a layout binding with input method
 **/
FCITX_EXPORT_API
void fcitx_kbd_set_layout_for_im(FcitxKbd *kbd, const gchar *imname,
                                 const gchar *layout, const gchar *variant) {
    g_dbus_proxy_call(G_DBUS_PROXY(kbd), "SetLayoutForIM",
                      g_variant_new("(sss)", imname, layout, variant),
                      G_DBUS_CALL_FLAGS_NO_AUTO_START, 0, NULL, NULL, NULL);
}
void
um_user_manager_delete_user (UmUserManager       *manager,
                             UmUser              *user,
                             gboolean             remove_files,
                             GAsyncReadyCallback  done,
                             gpointer             done_data,
                             GDestroyNotify       destroy)
{
        AsyncUserOpData *data;

        data = g_new0 (AsyncUserOpData, 1);
        data->manager = g_object_ref (manager);
        data->callback = done;
        data->data = done_data;
        data->destroy = destroy;

        g_dbus_proxy_call (manager->proxy,
                           "DeleteUser",
                           g_variant_new ("(xb)", (gint64) um_user_get_uid (user), remove_files),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
                           NULL,
                           delete_user_done,
                           data);
}
Exemple #30
0
static gboolean
handle_discover (CockpitRealms *object,
                 GDBusMethodInvocation *invocation,
                 const gchar *arg_name,
                 GVariant *arg_options)
{
  Realms *realms = REALMS (object);

  if (!auth_check_sender_role (invocation, COCKPIT_ROLE_REALM_ADMIN))
    return TRUE;

  GVariantBuilder discover_options;
  g_variant_builder_init (&discover_options, G_VARIANT_TYPE ("a{sv}"));

  copy_option (&discover_options, arg_options, "client-software");
  copy_option (&discover_options, arg_options, "server-software");

  struct DiscoverData *data = g_new0(struct DiscoverData, 1);
  data->realms = realms;
  data->invocation = invocation;

  g_dbus_proxy_call (realms->realmd,
                     "Discover",
                     g_variant_new ("(sa{sv})", arg_name, &discover_options),
                     G_DBUS_CALL_FLAGS_NONE,
                     G_MAXINT,
                     NULL,
                     on_discover_done,
                     data);

  return TRUE;
}