Ejemplo n.º 1
0
/**
 * fcitx_input_method_set_imlist:
 * @im: A #FcitxInputMethod
 * @array: (element-type FcitxIMItem) (transfer none): A #FcitxIMItem List
 *
 * Set Fcitx all im list
 **/
FCITX_EXPORT_API
void
fcitx_input_method_set_imlist(FcitxInputMethod *im, GPtrArray* array)
{
    GVariantBuilder builder;
    g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sssb)"));
    g_ptr_array_foreach(array, _fcitx_im_item_foreach_cb, &builder);
    GVariant* value = g_variant_builder_end(&builder);
    GError* error = NULL;
    GVariant* result = g_dbus_connection_call_sync(g_dbus_proxy_get_connection(G_DBUS_PROXY(im)),
                       g_dbus_proxy_get_name(G_DBUS_PROXY(im)),
                       FCITX_IM_DBUS_PATH,
                       "org.freedesktop.DBus.Properties",
                       "Set",
                       g_variant_new("(ssv)", FCITX_IM_DBUS_INTERFACE, "IMList", value),
                       G_VARIANT_TYPE_UNIT,
                       G_DBUS_CALL_FLAGS_NONE,
                       -1,           /* timeout */
                       NULL,
                       &error);

    if (error) {
        g_warning("%s", error->message);
        g_error_free(error);
    }

    g_variant_unref(result);
}
Ejemplo n.º 2
0
static gboolean
handle_prepare_print (XdpPrint *object,
                      GDBusMethodInvocation *invocation,
                      const gchar *arg_parent_window,
                      const gchar *arg_title,
                      GVariant *arg_settings,
                      GVariant *arg_page_setup,
                      GVariant *arg_options)
{
  Request *request = request_from_invocation (invocation);
  const char *app_id = xdp_app_info_get_id (request->app_info);
  g_autoptr(GError) error = NULL;
  g_autoptr(XdpImplRequest) impl_request = NULL;
  GVariantBuilder opt_builder;

  if (xdp_impl_lockdown_get_disable_printing (lockdown))
    {
      g_debug ("Printing disabled");
      g_dbus_method_invocation_return_error (invocation,
                                             XDG_DESKTOP_PORTAL_ERROR,
                                             XDG_DESKTOP_PORTAL_ERROR_NOT_ALLOWED,
                                             "Printing disabled");
      return TRUE;
    }

  REQUEST_AUTOLOCK (request);

  impl_request = xdp_impl_request_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (impl)),
                                                  G_DBUS_PROXY_FLAGS_NONE,
                                                  g_dbus_proxy_get_name (G_DBUS_PROXY (impl)),
                                                  request->id,
                                                  NULL, &error);
  if (!impl_request)
    {
      g_dbus_method_invocation_return_gerror (invocation, error);
      return TRUE;
    }

  request_set_impl_request (request, impl_request);
  request_export (request, g_dbus_method_invocation_get_connection (invocation));

  g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
  xdp_filter_options (arg_options, &opt_builder,
                      prepare_print_options, G_N_ELEMENTS (prepare_print_options));
  xdp_impl_print_call_prepare_print (impl,
                                     request->id,
                                     app_id,
                                     arg_parent_window,
                                     arg_title,
                                     arg_settings,
                                     arg_page_setup,
                                     g_variant_builder_end (&opt_builder),
                                     NULL,
                                     prepare_print_done,
                                     g_object_ref (request));

  xdp_print_complete_prepare_print (object, invocation, request->id);

  return TRUE;
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
static gboolean
mtn_connman_initable_init_sync (GInitable     *initable,
                                GCancellable  *cancellable,
                                GError       **error)
{
    GInitableIface *iface_class, *parent_iface_class;
    GVariant *var, *value;
    GVariantIter *iter;
    char *key;
    MtnConnman *connman;

    connman = MTN_CONNMAN (initable);

    /* Chain up the old method */
    iface_class = G_INITABLE_GET_IFACE (initable);
    parent_iface_class = g_type_interface_peek_parent (iface_class);
    if (!parent_iface_class->init (initable, cancellable, error)) {
        return FALSE;
    }

    g_signal_connect (connman, "notify::g-name-owner",
                      G_CALLBACK (_name_owner_notify_cb), NULL);

    var = g_dbus_proxy_call_sync (G_DBUS_PROXY (connman),
                                  "GetProperties",
                                  NULL,
                                  G_DBUS_CALL_FLAGS_NONE,
                                  -1,
                                  NULL,
                                  error);
    if (!var) {
        return FALSE;
    }

    g_variant_get (var, "(a{sv})", &iter);
    while (g_variant_iter_next (iter, "{sv}", &key, &value)) {
        g_hash_table_insert (connman->priv->properties,
                             key, value);
    }
    g_variant_iter_free (iter);
    g_variant_unref (var);

    var = g_dbus_proxy_call_sync (G_DBUS_PROXY (connman),
                                  "GetServices",
                                  NULL,
                                  G_DBUS_CALL_FLAGS_NONE,
                                  -1,
                                  NULL,
                                  error);
    if (!var) {
        return FALSE;
    }

    connman->priv->services = var;

    return TRUE;
}
Ejemplo n.º 5
0
static void
add_interface (JsonBuilder *builder,
               GDBusInterface *interface,
               GVariant *changed_properties)
{
  gchar *s;

  json_builder_set_member_name (builder, g_dbus_proxy_get_interface_name (G_DBUS_PROXY (interface)));
  json_builder_begin_object (builder);

  if (changed_properties == NULL)
    {
      gchar **properties;
      guint n;

      properties = g_dbus_proxy_get_cached_property_names (G_DBUS_PROXY (interface));
      for (n = 0; properties != NULL && properties[n] != NULL; n++)
        {
          const gchar *property_name = properties[n];
          GVariant *value;
          value = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (interface), property_name);
          if (value != NULL)
            {
              s = g_strconcat ("dbus_prop_", property_name, NULL);
              json_builder_set_member_name (builder, s);
              g_free (s);
              _json_builder_add_gvariant (builder, value);
              g_variant_unref (value);
            }
        }
      g_strfreev (properties);

      if (properties == NULL)
        {
          json_builder_set_member_name (builder, "HackEmpty");
          json_builder_add_string_value (builder, "HackEmpty");
        }
    }
  else
    {
      GVariantIter iter;
      const gchar *property_name;
      GVariant *value;
      g_variant_iter_init (&iter, changed_properties);
      while (g_variant_iter_next (&iter, "{&sv}", &property_name, &value))
        {
          s = g_strconcat ("dbus_prop_", property_name, NULL);
          json_builder_set_member_name (builder, property_name);
          g_free (s);
          _json_builder_add_gvariant (builder, value);
          g_variant_unref (value);
        }
    }

  json_builder_end_object (builder);
}
Ejemplo n.º 6
0
/**
 * fcitx_input_method_get_imlist_nofree: (rename-to fcitx_input_method_get_imlist)
 * @im: A #FcitxInputMethod
 *
 * Get Fcitx all im list
 *
 * Returns: (transfer full) (element-type FcitxIMItem): A #FcitxIMItem List
 *
 * Rename to: fcitx_input_method_get_imlist
 **/
FCITX_EXPORT_API
GPtrArray*
fcitx_input_method_get_imlist_nofree(FcitxInputMethod* im)
{
    GPtrArray *array = NULL;
    GVariant* value;
    GVariantIter *iter;
    gchar *name, *unique_name, *langcode;
    gboolean enable;
    value = g_dbus_proxy_get_cached_property(G_DBUS_PROXY(im), "IMList");

    if (value == NULL) {
        GError* error = NULL;
        GVariant* result = g_dbus_connection_call_sync(g_dbus_proxy_get_connection(G_DBUS_PROXY(im)),
                           g_dbus_proxy_get_name(G_DBUS_PROXY(im)),
                           FCITX_IM_DBUS_PATH,
                           "org.freedesktop.DBus.Properties",
                           "Get",
                           g_variant_new("(ss)", FCITX_IM_DBUS_INTERFACE, "IMList"),
                           G_VARIANT_TYPE("(v)"),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,           /* timeout */
                           NULL,
                           &error);

        if (error) {
            g_warning("%s", error->message);
            g_error_free(error);
        } else if (result) {
            g_variant_get(result, "(v)", &value);
            g_variant_unref(result);
        }
    }

    if (value) {
        array = g_ptr_array_new();
        g_variant_get(value, "a(sssb)", &iter);
        while (g_variant_iter_next(iter, "(sssb)", &name, &unique_name, &langcode, &enable, NULL)) {
            FcitxIMItem *item = g_slice_new(FcitxIMItem);
            item->name = name;
            item->unique_name = unique_name;
            item->langcode = langcode;
            item->enable = enable;
            g_ptr_array_add(array, item);
        }
        g_variant_iter_free(iter);

        g_variant_unref(value);
    }

    return array;
}
Ejemplo n.º 7
0
static gboolean
handle_save_file (XdpFileChooser *object,
                  GDBusMethodInvocation *invocation,
                  const gchar *arg_parent_window,
                  const gchar *arg_title,
                  GVariant *arg_options)
{
  Request *request = request_from_invocation (invocation);
  const char *app_id = request->app_id;
  g_autoptr(GError) error = NULL;
  XdpImplRequest *impl_request;
  GVariantBuilder options;

  REQUEST_AUTOLOCK (request);

  g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT);
  xdp_filter_options (arg_options, &options,
                      save_file_options, G_N_ELEMENTS (save_file_options));

  impl_request = xdp_impl_request_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (impl)),
                                                  G_DBUS_PROXY_FLAGS_NONE,
                                                  g_dbus_proxy_get_name (G_DBUS_PROXY (impl)),
                                                  request->id,
                                                  NULL, &error);
  if (!impl_request)
    {
      g_dbus_method_invocation_return_gerror (invocation, error);
      return TRUE;
    }

  g_object_set_data (G_OBJECT (request), "for-save", GINT_TO_POINTER (TRUE));

  request_set_impl_request (request, impl_request);
  request_export (request, g_dbus_method_invocation_get_connection (invocation));

  xdp_impl_file_chooser_call_save_file (impl,
                                        request->id,
                                        app_id,
                                        arg_parent_window,
                                        arg_title,
                                        g_variant_builder_end (&options),
                                        NULL,
                                        save_file_done,
                                        g_object_ref (request));

  xdp_file_chooser_complete_open_file (object, invocation, request->id);

  return TRUE;
}
Ejemplo n.º 8
0
static gboolean
handle_empty_device (CockpitStorageVolumeGroup *object,
                     GDBusMethodInvocation *invocation,
                     const gchar *arg_objpath)
{
  StorageVolumeGroup *group = STORAGE_VOLUME_GROUP(object);
  GError *error = NULL;
  const gchar *block_path = "/";

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

  StorageProvider *provider = storage_object_get_provider (group->object);
  Daemon *daemon = storage_provider_get_daemon (provider);
  GDBusObjectManagerServer *object_manager_server = daemon_get_object_manager (daemon);
  GDBusObjectManager *object_manager = G_DBUS_OBJECT_MANAGER (object_manager_server);

  StorageObject *block_object =
    STORAGE_OBJECT (g_dbus_object_manager_get_object (object_manager, arg_objpath));
  UDisksBlock *udisks_block = storage_object_get_udisks_block (block_object);

  if (udisks_block)
    block_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (udisks_block));

  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (group->lvm_volume_group),
                                    G_MAXINT);

  if (!lvm_volume_group_call_empty_device_sync (group->lvm_volume_group,
                                                block_path,
                                                null_asv (),
                                                NULL,
                                                &error))
    {
      g_dbus_error_strip_remote_error (error);
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "%s", error->message);
      g_error_free (error);
    }
  else
    cockpit_storage_volume_group_complete_empty_device (object, invocation);

  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (group->lvm_volume_group),
                                    -1);

  return TRUE;
}
Ejemplo n.º 9
0
const gchar *
storage_block_get_object_path (StorageBlock *self)
{
  g_return_val_if_fail (STORAGE_IS_BLOCK (self), NULL);
  g_return_val_if_fail (self->real_block != NULL, NULL);
  return g_dbus_proxy_get_object_path (G_DBUS_PROXY (self->real_block));
}
Ejemplo n.º 10
0
static void
on_udisks_object_added (GDBusObjectManager *manager,
                        GDBusObject *object,
                        gpointer user_data)
{
  FormatData *data = user_data;

  if (data->invocation == NULL)
    return;

  UDisksObject *udisks_object = UDISKS_OBJECT (object);
  UDisksJob *udisks_job = udisks_object_peek_job (udisks_object);
  if (udisks_job)
    {
      const gchar *us = g_dbus_proxy_get_object_path (G_DBUS_PROXY (data->block));
      const gchar *const *them = udisks_job_get_objects (udisks_job);
      for (int i = 0; them[i]; i++)
        {
          if (strcmp (them[i], us) == 0)
            {
              g_dbus_method_invocation_return_value (data->invocation, g_variant_new ("()"));
              g_clear_object (&data->invocation);
              break;
            }
        }
    }
}
static void
inhibit_done (GObject      *source,
              GAsyncResult *result,
              gpointer      user_data)
{
    GDBusProxy *sd_proxy = G_DBUS_PROXY (source);
    NMSleepMonitor *self = user_data;
    GError *error = NULL;
    GVariant *res;
    GUnixFDList *fd_list;

    res = g_dbus_proxy_call_with_unix_fd_list_finish (sd_proxy, &fd_list, result, &error);
    if (!res) {
        g_dbus_error_strip_remote_error (error);
        nm_log_warn (LOGD_SUSPEND, "Inhibit failed: %s", error->message);
        g_error_free (error);
    } else {
        if (!fd_list || g_unix_fd_list_get_length (fd_list) != 1)
            nm_log_warn (LOGD_SUSPEND, "Didn't get a single fd back");

        self->inhibit_fd = g_unix_fd_list_get (fd_list, 0, NULL);

        nm_log_dbg (LOGD_SUSPEND, "Inhibitor fd is %d", self->inhibit_fd);
        g_object_unref (fd_list);
        g_variant_unref (res);
    }
}
Ejemplo n.º 12
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);
}
Ejemplo n.º 13
0
static void
_set_property_cb (GObject *object,
                  GAsyncResult *res,
                  gpointer user_data)
{
    char *key;
    GVariant *var;
    GError *error;

    key = (char *)user_data;
    error = NULL;

    var = g_dbus_proxy_call_finish (G_DBUS_PROXY (object),
                                    res,
                                    &error);
    if (var) {
        g_variant_unref (var);
    } else if (error) {
        g_warning ("Connman Manager.SetProperty() for '%s' failed: %s",
                   key, error->message);

        /* TODO: call a error handler method */
        g_error_free (error);
    }

    g_free (key);
}
Ejemplo n.º 14
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);
}
Ejemplo n.º 15
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);
}
Ejemplo n.º 16
0
SecretPrompt *
_secret_prompt_instance (SecretService *service,
                         const gchar *prompt_path)
{
	GDBusProxy *proxy;
	SecretPrompt *prompt;
	GError *error = NULL;

	g_return_val_if_fail (SECRET_IS_SERVICE (service), NULL);
	g_return_val_if_fail (prompt_path != NULL, NULL);

	proxy = G_DBUS_PROXY (service);
	prompt = g_initable_new (SECRET_TYPE_PROMPT, NULL, &error,
	                         "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
	                         "g-interface-info", _secret_gen_prompt_interface_info (),
	                         "g-name", g_dbus_proxy_get_name (proxy),
	                         "g-connection", g_dbus_proxy_get_connection (proxy),
	                         "g-object-path", prompt_path,
	                         "g-interface-name", SECRET_PROMPT_INTERFACE,
	                         NULL);

	if (error != NULL) {
		g_warning ("couldn't create SecretPrompt object: %s", error->message);
		g_clear_error (&error);
		return NULL;
	}

	return prompt;
}
Ejemplo n.º 17
0
static void
on_prompt_dismissed (GObject *source,
                     GAsyncResult *result,
                     gpointer user_data)
{
	GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
	PerformClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
	SecretPrompt *self = SECRET_PROMPT (source);
	GError *error = NULL;
	GVariant *retval;

	retval = g_dbus_proxy_call_finish (G_DBUS_PROXY (self), result, &error);

	if (retval)
		g_variant_unref (retval);
	if (closure->vanished)
		g_clear_error (&error);
	if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD))
		g_clear_error (&error);

	if (error != NULL) {
		g_simple_async_result_take_error (res, error);
		perform_prompt_complete (res, TRUE);
	}

	g_object_unref (res);
}
Ejemplo n.º 18
0
static void
on_prompt_prompted (GObject *source,
                    GAsyncResult *result,
                    gpointer user_data)
{
	GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
	PerformClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
	SecretPrompt *self = SECRET_PROMPT (source);
	GError *error = NULL;
	GVariant *retval;

	retval = g_dbus_proxy_call_finish (G_DBUS_PROXY (self), result, &error);

	if (retval)
		g_variant_unref (retval);
	if (closure->vanished)
		g_clear_error (&error);

	if (error != NULL) {
		g_simple_async_result_take_error (res, error);
		perform_prompt_complete (res, TRUE);

	} else {
		closure->prompting = TRUE;
		g_atomic_int_set (&self->pv->prompted, 1);

		/* And now we wait for the signal */
	}

	g_object_unref (res);
}
Ejemplo n.º 19
0
static void get_capabilities_callback(GObject* source, GAsyncResult* res, gpointer user_data UNUSED)
{
    char** caps;
    GVariant* result;

    result = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, NULL);

    if (result == NULL || !g_variant_is_of_type(result, G_VARIANT_TYPE("(as)")))
    {
        if (result != NULL)
        {
            g_variant_unref(result);
        }

        return;
    }

    g_variant_get(result, "(^a&s)", &caps);

    for (int i = 0; caps[i] != NULL; i++)
    {
        if (g_strcmp0(caps[i], "actions") == 0)
        {
            server_supports_actions = TRUE;
            break;
        }
    }

    g_free(caps);
    g_variant_unref(result);
}
Ejemplo n.º 20
0
/**
 * fcitx_input_method_get_current_state:
 * @im: A #FcitxInputMethod
 *
 * Get current state
 *
 * Returns: current state, -1 for error
 **/
FCITX_EXPORT_API
gint fcitx_input_method_get_current_state(FcitxInputMethod* im)
{
    GError* error = NULL;
    GVariant* variant = g_dbus_proxy_call_sync(G_DBUS_PROXY(im),
                                               "GetCurrentState",
                                               NULL,
                                               G_DBUS_CALL_FLAGS_NO_AUTO_START,
                                               -1,
                                               NULL,
                                               &error
                                              );

    gint result = -1;

    if (error) {
        g_warning("%s", error->message);
        g_error_free(error);
    } else if (variant) {
        g_variant_get(variant, "(i)", &result);
        g_variant_unref(variant);
    }

    return result;
}
Ejemplo n.º 21
0
/**
 * fcitx_input_method_get_im_addon:
 * @im: A #FcitxInputMethod
 * @imname: (transfer none): imname
 *
 * Get addon name by im
 *
 * Returns: (transfer full): get addon name
 **/
FCITX_EXPORT_API
gchar* fcitx_input_method_get_im_addon(FcitxInputMethod* im, gchar* imname)
{
    GError* error = NULL;
    GVariant* variant = g_dbus_proxy_call_sync(G_DBUS_PROXY(im),
                                               "GetIMAddon",
                                               g_variant_new("(s)", imname),
                                               G_DBUS_CALL_FLAGS_NO_AUTO_START,
                                               -1,
                                               NULL,
                                               &error
                                              );

    gchar* result = NULL;

    if (error) {
        g_warning("%s", error->message);
        g_error_free(error);
    } else if (variant) {
        g_variant_get(variant, "(s)", &result);
        g_variant_unref(variant);
    }

    return result;
}
Ejemplo n.º 22
0
static void
storage_manager_constructed (GObject *_object)
{
  StorageManager *storage_manager = STORAGE_MANAGER (_object);
  GError *error = NULL;

  storage_manager->udisks = udisks_client_new_sync (NULL, &error);
  if (storage_manager->udisks == NULL)
    {
      g_warning ("Error connecting to udisks: %s (%s, %d)",
                 error->message, g_quark_to_string (error->domain), error->code);
      g_clear_error (&error);
    }

  storage_manager->lvm_manager =
    lvm_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
                                        0,
                                        "com.redhat.storaged",
                                        "/org/freedesktop/UDisks2/Manager",
                                        NULL,
                                        &error);
  if (storage_manager->lvm_manager == NULL)
    {
      g_warning ("Error connecting to storaged: %s (%s, %d)",
                 error->message, g_quark_to_string (error->domain), error->code);
      g_clear_error (&error);
    }

  g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (storage_manager->lvm_manager), G_MAXINT);

  if (G_OBJECT_CLASS (storage_manager_parent_class)->constructed != NULL)
    G_OBJECT_CLASS (storage_manager_parent_class)->constructed (_object);
}
static void
goa_dlna_server_manager_server_new_cb (GObject      *source_object,
                                       GAsyncResult *res,
                                       gpointer      user_data)
{
  GoaDlnaServerManager *self = GOA_DLNA_SERVER_MANAGER (user_data);
  DleynaServerMediaDevice *server;
  GError *error = NULL;
  const gchar *object_path;

  server = dleyna_server_media_device_proxy_new_for_bus_finish (res, &error);
  if (error != NULL)
    {
      g_warning ("Unable to load server object: %s", error->message);
      g_error_free (error);
      goto out;
    }

  object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (server));

  g_debug ("%s '%s' %s %s",
           G_STRFUNC,
           dleyna_server_media_device_get_friendly_name (server),
           dleyna_server_media_device_get_udn (server),
           object_path);
  g_hash_table_insert (self->servers, (gpointer) object_path, server);
  g_signal_emit (self, signals[SERVER_FOUND], 0, server);

 out:
  g_object_unref (self);
}
Ejemplo n.º 24
0
/**
 * gca_service_call_parse_sync:
 * @proxy: A #GcaServiceProxy.
 * @arg_path: Argument to pass with the method invocation.
 * @arg_data_path: Argument to pass with the method invocation.
 * @arg_cursor: Argument to pass with the method invocation.
 * @arg_options: Argument to pass with the method invocation.
 * @out_unnamed_arg4: (out): Return location for return parameter or %NULL to ignore.
 * @cancellable: (allow-none): A #GCancellable or %NULL.
 * @error: Return location for error or %NULL.
 *
 * Synchronously invokes the <link linkend="gdbus-method-org-gnome-CodeAssist-v1-Service.Parse">Parse()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
 *
 * See gca_service_call_parse() for the asynchronous version of this method.
 *
 * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
 */
gboolean
gca_service_call_parse_sync (
    GcaService *proxy,
    const gchar *arg_path,
    const gchar *arg_data_path,
    GVariant *arg_cursor,
    GVariant *arg_options,
    gchar **out_unnamed_arg4,
    GCancellable *cancellable,
    GError **error)
{
  GVariant *_ret;
  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
    "Parse",
    g_variant_new ("(ss@(xx)@a{sv})",
                   arg_path,
                   arg_data_path,
                   arg_cursor,
                   arg_options),
    G_DBUS_CALL_FLAGS_NONE,
    -1,
    cancellable,
    error);
  if (_ret == NULL)
    goto _out;
  g_variant_get (_ret,
                 "(o)",
                 out_unnamed_arg4);
  g_variant_unref (_ret);
_out:
  return _ret != NULL;
}
Ejemplo n.º 25
0
static void
_get_services_cb (GObject      *obj,
                  GAsyncResult *res,
                  gpointer      user_data)
{
    MtnConnman *connman;
    GError *error;
    GVariant *var;
    InitData *data;

    connman = MTN_CONNMAN (obj);
    data = (InitData*)user_data;

    error = NULL;
    var = g_dbus_proxy_call_finish (G_DBUS_PROXY (obj), res, &error);
    if (!var) {
        g_warning ("Initial GetServices() failed: %s\n",
                   error->message);
        g_error_free (error);
    } else {
      connman->priv->services = var;
    }

    if (data->done_props) {
        g_simple_async_result_complete_in_idle (data->res);
        g_object_unref (data->res);
        g_free (data);
    } else {
      data->done_services = TRUE;
    }
}
static void
on_client_registered (GObject             *source_object,
                      GAsyncResult        *res,
                      gpointer             user_data)
{
        GVariant *variant;
        GError *error = NULL;
        gchar *object_path = NULL;

        variant = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
        if (error != NULL) {
                g_warning ("Unable to register client: %s", error->message);
                g_error_free (error);
        } else {
                g_variant_get (variant, "(o)", &object_path);

                g_debug ("Registered client at path %s", object_path);

                g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, 0, NULL,
                                          GNOME_SESSION_DBUS_NAME,
                                          object_path,
                                          GNOME_SESSION_CLIENT_PRIVATE_DBUS_INTERFACE,
                                          NULL,
                                          got_client_proxy,
                                          manager);

                g_free (object_path);
                g_variant_unref (variant);
        }
}
Ejemplo n.º 27
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);
}
Ejemplo n.º 28
0
static void
default_adapter_cb (GObject *proxy, GAsyncResult *result, gpointer user_data)
{
	NMBluez4Manager *self = NM_BLUEZ4_MANAGER (user_data);
	NMBluez4ManagerPrivate *priv = NM_BLUEZ4_MANAGER_GET_PRIVATE (self);
	GVariant *ret;
	GError *err = NULL;

	ret = _nm_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), result,
	                                  G_VARIANT_TYPE ("(o)"), &err);
	if (ret) {
		const char *default_adapter;

		g_variant_get (ret, "(&o)", &default_adapter);
		default_adapter_changed (priv->proxy, default_adapter, self);
		g_variant_unref (ret);
	} else {
		/* Ignore "No such adapter" errors; just means bluetooth isn't active */
		if (   !_nm_dbus_error_has_name (err, "org.bluez.Error.NoSuchAdapter")
		    && !_nm_dbus_error_has_name (err, "org.freedesktop.systemd1.LoadFailed")
		    && !g_error_matches (err, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN)) {
			g_dbus_error_strip_remote_error (err);
			nm_log_warn (LOGD_BT, "bluez error getting default adapter: %s",
			             err->message);
		}
		g_error_free (err);
	}
}
static void
install_mime_types_ready_cb (GObject      *source,
                             GAsyncResult *res,
                             gpointer      user_data)
{
  GtkAppChooserOnlinePk *self = user_data;
  GDBusProxy *proxy = G_DBUS_PROXY (source);
  GError *error = NULL;
  GVariant *variant;

  variant = g_dbus_proxy_call_finish (proxy, res, &error);

  if (variant == NULL)
    {
      /* don't show errors if the user cancelled the installation explicitely
       * or if PK wasn't able to find any apps
       */
      if (g_strcmp0 (g_dbus_error_get_remote_error (error), "org.freedesktop.PackageKit.Modify.Cancelled") != 0 &&
          g_strcmp0 (g_dbus_error_get_remote_error (error), "org.freedesktop.PackageKit.Modify.NoPackagesFound") != 0)
        g_simple_async_result_set_from_error (self->priv->result, error);

      g_error_free (error);
    }

  g_simple_async_result_complete (self->priv->result);
  g_clear_object (&self->priv->result);
}
Ejemplo n.º 30
0
static void
on_get_unit_file_state_done (GObject *object,
                             GAsyncResult *res,
                             gpointer user_data)
{
  GetServiceInfoData *data = user_data;
  GError *error = NULL;

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

  const gchar *state;
  g_variant_get (result, "(&s)", &state);

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

  g_variant_builder_add (&bob, "{sv}", "Id", g_variant_new_string (data->name));
  g_variant_builder_add (&bob, "{sv}", "IsTemplate", g_variant_new_boolean (TRUE));
  g_variant_builder_add (&bob, "{sv}", "UnitFileState", g_variant_new_string (state));

  cockpit_services_complete_get_service_info (COCKPIT_SERVICES (data->services), data->invocation,
                                              g_variant_builder_end (&bob));
  g_free (data->name);
  g_free (data);
}