Пример #1
0
static gboolean
handle_uninstall (FlatpakSystemHelper *object,
                  GDBusMethodInvocation *invocation,
                  guint arg_flags,
                  const gchar *arg_ref)
{
  g_autoptr(FlatpakDir) system = dir_get_system ();
  g_autoptr(GError) error = NULL;

  g_debug ("Uninstall %u %s", arg_flags, arg_ref);

  if ((arg_flags & ~FLATPAK_HELPER_UNINSTALL_FLAGS_ALL) != 0)
    {
      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                             "Unsupported flags enabled: 0x%x", (arg_flags & ~FLATPAK_HELPER_UNINSTALL_FLAGS_ALL));
      return TRUE;
    }

  if (!flatpak_dir_ensure_repo (system, NULL, &error))
    {
      g_dbus_method_invocation_return_gerror  (invocation, error);
      return TRUE;
    }

  if (!flatpak_dir_uninstall (system, arg_ref, arg_flags, NULL, &error))
    {
      g_dbus_method_invocation_return_gerror  (invocation, error);
      return TRUE;
    }

  flatpak_system_helper_complete_uninstall (object, invocation);

  return TRUE;
}
/*
 * This handler is run in a separate thread, so all operations can be
 * synchronous.
 */
static gboolean
on_authorize_method_check (GDBusInterfaceSkeleton *interface,
                           GDBusMethodInvocation  *invocation,
                           EmerDaemon             *daemon)
{
  const gchar *method_name =
    g_dbus_method_invocation_get_method_name (invocation);
  const AuthorizedMethod *authorized_method = lookup_authorized_method (method_name);

  if (authorized_method == NULL)
    return TRUE;

  GError *error = NULL;
  PolkitAuthority *authority =
    polkit_authority_get_sync (NULL /*GCancellable*/, &error);
  if (authority == NULL)
    {
      g_critical ("Could not get PolicyKit authority: %s.", error->message);
      g_dbus_method_invocation_return_gerror (invocation, error);
      g_error_free (error);
      return FALSE;
    }

  const gchar *sender_name = g_dbus_method_invocation_get_sender (invocation);
  PolkitSubject *subject = polkit_system_bus_name_new (sender_name);

  PolkitAuthorizationResult *result =
    polkit_authority_check_authorization_sync (authority,
                                               subject,
                                               authorized_method->method_full_name,
                                               NULL /*PolkitDetails*/,
                                               POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
                                               NULL /*GCancellable*/,
                                               &error);
  g_object_unref (authority);
  g_object_unref (subject);
  if (result == NULL)
    {
      g_critical ("Could not get PolicyKit authorization result: %s.",
                  error->message);
      g_dbus_method_invocation_return_gerror (invocation, error);
      g_error_free (error);
      return FALSE;
    }

  gboolean authorized = polkit_authorization_result_get_is_authorized (result);
  if (!authorized)
    g_dbus_method_invocation_return_error_literal (invocation,
                                                   G_DBUS_ERROR,
                                                   G_DBUS_ERROR_AUTH_FAILED,
                                                   authorized_method->error_message);

  g_object_unref (result);
  return authorized;
}
Пример #3
0
/**
 * cd_sensor_get_sample_cb:
 **/
static void
cd_sensor_get_sample_cb (GObject *source_object,
			 GAsyncResult *res,
			 gpointer user_data)
{
	GVariant *result = NULL;
	CdColorXYZ *sample;
	CdSensor *sensor = CD_SENSOR (source_object);
	GDBusMethodInvocation *invocation = (GDBusMethodInvocation *) user_data;
	GError *error = NULL;

	/* get the result */
	sample = sensor->priv->desc->get_sample_finish (sensor, res, &error);
	if (sample == NULL) {
		g_dbus_method_invocation_return_gerror (invocation,
							error);
		g_error_free (error);
		goto out;
	}

	/* return value */
	g_debug ("returning value %f, %f, %f",
		 sample->X,
		 sample->Y,
		 sample->Z);
	result = g_variant_new ("(ddd)",
				sample->X,
				sample->Y,
				sample->Z);
	g_dbus_method_invocation_return_value (invocation, result);
out:
	if (sample != NULL)
		cd_color_xyz_free (sample);
}
Пример #4
0
static void
sniff_async_ready_cb (GObject *source,
                      GAsyncResult *res,
                      gpointer user_data)
{
  InvocationData *data = user_data;
  gchar **types;
  GError *error = NULL;

  types = cinnamon_mime_sniffer_sniff_finish (CINNAMON_MIME_SNIFFER (source),
                                           res, &error);

  if (error != NULL)
    {
      g_dbus_method_invocation_return_gerror (data->invocation, error);
      g_error_free (error);
      goto out;
    }

  g_dbus_method_invocation_return_value (data->invocation,
                                         g_variant_new ("(^as)", types));
  g_strfreev (types);

 out:
  invocation_data_free (data);
  ensure_autoquit_on ();
}
Пример #5
0
static void _dbus_steadyflow_iapp_service_set_visible (SteadyflowIAppService* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gboolean visible = FALSE;
	GVariant* _tmp1_;
	GDBusMessage* _reply_message;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, parameters);
	_tmp1_ = g_variant_iter_next_value (&_arguments_iter);
	visible = g_variant_get_boolean (_tmp1_);
	g_variant_unref (_tmp1_);
	steadyflow_iapp_service_set_visible (self, visible, &error);
	if (error) {
		g_dbus_method_invocation_return_gerror (invocation, error);
		return;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
}
Пример #6
0
static gboolean
handle_close (XdpRequest *object,
              GDBusMethodInvocation *invocation,
              Request *request)
{
  g_autoptr(GError) error = NULL;

  REQUEST_AUTOLOCK (request);

  if (request->exported)
    {
      const char *handle = g_object_get_data (G_OBJECT (request), "impl-handle");

      if (!xdp_impl_file_chooser_call_close_sync (impl,
                                                  request->sender, request->app_id, handle,
                                                  NULL, &error))
        {
          g_dbus_method_invocation_return_gerror (invocation, error);
          return TRUE;
        }

      unregister_handle (handle);
      request_unexport (request);
    }

  xdp_request_complete_close (XDP_REQUEST (request), invocation);

  return TRUE;
}
Пример #7
0
static gboolean
handle_set_profile (MmGdbusTest *skeleton,
                    GDBusMethodInvocation *invocation,
                    const gchar *id,
                    const gchar *plugin_name,
                    const gchar *const *ports,
                    MMBaseManager *self)
{
    MMPlugin *plugin;
    MMDevice *device;
    gchar *physdev;
    GError *error = NULL;

    mm_info ("Test profile set to: '%s'", id);

    /* Create device and keep it listed in the Manager */
    physdev = g_strdup_printf ("/virtual/%s", id);
    device = mm_device_virtual_new (physdev, TRUE);
    g_hash_table_insert (self->priv->devices, physdev, device);

    /* Grab virtual ports */
    mm_device_virtual_grab_ports (device, (const gchar **)ports);

    /* Set plugin to use */
    plugin = mm_plugin_manager_peek_plugin (self->priv->plugin_manager, plugin_name);
    if (!plugin) {
        error = g_error_new (MM_CORE_ERROR,
                             MM_CORE_ERROR_NOT_FOUND,
                             "Requested plugin '%s' not found",
                             plugin_name);
        mm_warn ("Couldn't set plugin for virtual device at '%s': %s",
                 mm_device_get_path (device),
                 error->message);
        goto out;
    }
    mm_device_set_plugin (device, G_OBJECT (plugin));

    /* Create modem */
    if (!mm_device_create_modem (device, self->priv->object_manager, &error)) {
        mm_warn ("Couldn't create modem for virtual device at '%s': %s",
                 mm_device_get_path (device),
                 error->message);
        goto out;
    }

    mm_info ("Modem for virtual device at '%s' successfully created",
             mm_device_get_path (device));

out:

    if (error) {
        mm_device_remove_modem (device);
        g_hash_table_remove (self->priv->devices, mm_device_get_path (device));
        g_dbus_method_invocation_return_gerror (invocation, error);
        g_error_free (error);
    } else
        mm_gdbus_test_complete_set_profile (skeleton, invocation);

    return TRUE;
}
Пример #8
0
static void
korva_server_on_push_async_ready (GObject      *obj,
                                  GAsyncResult *res,
                                  gpointer      user_data)
{
    KorvaDevice *device = KORVA_DEVICE (obj);
    PushAsyncData *data = (PushAsyncData *) user_data;
    GError *error = NULL;
    char *tag;

    tag = korva_device_push_finish (device, res, &error);
    if (tag == NULL) {
        g_dbus_method_invocation_return_gerror (data->invocation,
                                                error);

        goto out;
    }

    g_hash_table_insert (data->self->priv->tags,
                         g_strdup (tag),
                         g_strdup (korva_device_get_uid (device)));

    korva_controller1_complete_push (data->self->priv->dbus_controller, data->invocation, tag);
    g_free (tag);

out:
    g_free (data);
}
Пример #9
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;
}
Пример #10
0
static void
handle_result(GDBusMethodInvocation *invocation,
			gboolean ret,
			GError *error)
{
	if (ret)
	{
		g_dbus_method_invocation_return_value(invocation, NULL);
	}
	else
	{
		if (error != NULL)
		{
			xmr_debug("mpris: returning error: %s", error->message);
			g_dbus_method_invocation_return_gerror(invocation, error);
			g_error_free(error);
		}
		else
		{
			xmr_debug("mpris: returning unknown error");
			g_dbus_method_invocation_return_error_literal(invocation,
						G_DBUS_ERROR,
						G_DBUS_ERROR_FAILED,
						"Unknown error");
		}
	}
}
Пример #11
0
static void prv_connector_return_error(dleyna_connector_msg_id_t message_id,
				       const GError *error)
{
	g_dbus_method_invocation_return_gerror(
					(GDBusMethodInvocation *)message_id,
					error);
}
Пример #12
0
/**
 * cd_sensor_get_sample_cb:
 **/
static void
cd_sensor_get_sample_cb (GObject *source_object,
			 GAsyncResult *res,
			 gpointer user_data)
{
	GVariant *result = NULL;
	g_autoptr(CdColorXYZ) sample = NULL;
	CdSensor *sensor = CD_SENSOR (source_object);
	CdSensorPrivate *priv = GET_PRIVATE (sensor);
	GDBusMethodInvocation *invocation = (GDBusMethodInvocation *) user_data;
	g_autoptr(GError) error = NULL;

	/* set here to avoid every sensor doing this */
	cd_sensor_set_state (sensor, CD_SENSOR_STATE_IDLE);

	/* get the result */
	sample = priv->desc->get_sample_finish (sensor, res, &error);
	if (sample == NULL) {
		g_dbus_method_invocation_return_gerror (invocation, error);
		return;
	}

	/* return value */
	g_debug ("returning value %f, %f, %f", sample->X, sample->Y, sample->Z);
	result = g_variant_new ("(ddd)", sample->X, sample->Y, sample->Z);
	g_dbus_method_invocation_return_value (invocation, result);
}
Пример #13
0
static gboolean
perform_writeback_cb (gpointer user_data)
{
	TrackerControllerPrivate *priv;
	WritebackData *data;

	data = user_data;
	priv = data->controller->priv;
	priv->ongoing_tasks = g_list_remove (priv->ongoing_tasks, data);

	if (data->error == NULL) {
		g_dbus_method_invocation_return_value (data->invocation, NULL);
	} else {
		g_dbus_method_invocation_return_gerror (data->invocation, data->error);
	}

	tracker_dbus_request_end (data->request, NULL);

	g_mutex_lock (&priv->mutex);
	priv->current = NULL;
	g_mutex_unlock (&priv->mutex);

	writeback_data_free (data);

	return FALSE;
}
/**
 * g_dbus_method_invocation_take_error: (skip)
 * @invocation: (transfer full): A #GDBusMethodInvocation.
 * @error: (transfer full): A #GError.
 *
 * Like g_dbus_method_invocation_return_gerror() but takes ownership
 * of @error so the caller does not need to free it.
 *
 * This method will free @invocation, you cannot use it afterwards.
 *
 * Since: 2.30
 */
void
g_dbus_method_invocation_take_error (GDBusMethodInvocation *invocation,
                                     GError                *error)
{
  g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation));
  g_return_if_fail (error != NULL);
  g_dbus_method_invocation_return_gerror (invocation, error);
  g_error_free (error);
}
static void
infinoted_plugin_dbus_set_acl(InfinotedPluginDbus* plugin,
                              InfinotedPluginDbusInvocation* invocation,
                              InfBrowser* browser,
                              const InfBrowserIter* iter)
{
  GVariant* sheet_set_variant;
  InfAclSheetSet* sheet_set;
  GError* error;
  InfRequest* request;

  g_variant_get_child(
    invocation->parameters,
    1,
    "@a{sa{sb}}",
    &sheet_set_variant
  );

  error = NULL;
  sheet_set = infinoted_plugin_dbus_sheet_set_from_variant(
    sheet_set_variant,
    &error
  );

  g_variant_unref(sheet_set_variant);

  if(error != NULL)
  {
    g_dbus_method_invocation_return_gerror(invocation->invocation, error);
    g_error_free(error);
    infinoted_plugin_dbus_invocation_free(plugin, invocation);
  }
  else
  {
    request = inf_browser_set_acl(
      browser,
      iter,
      sheet_set,
      infinoted_plugin_dbus_set_acl_finished_cb,
      invocation
    );

    inf_acl_sheet_set_free(sheet_set);

    if(request != NULL)
    {
      invocation->request = request;
      invocation->request_func = infinoted_plugin_dbus_set_acl_finished_cb;
    }
  }
}
Пример #16
0
void rsu_task_fail_and_delete(rsu_task_t *task, GError *error)
{
	if (!task)
		goto finished;

	if (task->invocation)
		g_dbus_method_invocation_return_gerror(task->invocation, error);

	prv_rsu_task_delete(task);

finished:

	return;
}
Пример #17
0
static void
ppp_secrets_cb (NMActRequest *req,
                NMActRequestGetSecretsCallId call_id,
                NMSettingsConnection *settings_connection, /* unused (we pass NULL here) */
                GError *error,
                gpointer user_data)
{
	NMPPPManager *self = NM_PPP_MANAGER (user_data);
	NMPPPManagerPrivate *priv = NM_PPP_MANAGER_GET_PRIVATE (self);
	const char *username = NULL;
	const char *password = NULL;
	GError *local = NULL;
	NMConnection *applied_connection;

	g_return_if_fail (priv->pending_secrets_context != NULL);
	g_return_if_fail (req == priv->act_req);
	g_return_if_fail (call_id == priv->secrets_id);

	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
		goto out;

	if (error) {
		_LOGW ("%s", error->message);
		g_dbus_method_invocation_return_gerror (priv->pending_secrets_context, error);
		goto out;
	}

	applied_connection = nm_act_request_get_applied_connection (req);

	if (!extract_details_from_connection (applied_connection, priv->secrets_setting_name, &username, &password, &local)) {
		_LOGW ("%s", local->message);
		g_dbus_method_invocation_take_error (priv->pending_secrets_context, local);
		goto out;
	}

	/* This is sort of a hack but...
	 * pppd plugin only ever needs username and password. Passing the full
	 * connection there would mean some bloat: the plugin would need to link
	 * against libnm just to parse this. So instead, let's just send what
	 * it needs.
	 */
	g_dbus_method_invocation_return_value (
		priv->pending_secrets_context,
		g_variant_new ("(ss)", username ? username : "", password ? password : ""));

 out:
	priv->pending_secrets_context = NULL;
	priv->secrets_id = NULL;
	priv->secrets_setting_name = NULL;
}
Пример #18
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;
}
/**
 * g_dbus_method_invocation_return_error_literal:
 * @invocation: A #GDBusMethodInvocation.
 * @domain: A #GQuark for the #GError error domain.
 * @code: The error code.
 * @message: The error message.
 *
 * Like g_dbus_method_invocation_return_error() but without printf()-style formatting.
 *
 * This method will free @invocation, you cannot use it afterwards.
 *
 * Since: 2.26
 */
void
g_dbus_method_invocation_return_error_literal (GDBusMethodInvocation *invocation,
                                               GQuark                 domain,
                                               gint                   code,
                                               const gchar           *message)
{
  GError *error;

  g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation));
  g_return_if_fail (message != NULL);

  error = g_error_new_literal (domain, code, message);
  g_dbus_method_invocation_return_gerror (invocation, error);
  g_error_free (error);
}
Пример #20
0
static void
ensure_credentials_cb (GoaProvider   *provider,
                       GAsyncResult  *res,
                       gpointer       user_data)
{
  EnsureData *data = user_data;
  gint expires_in;
  GError *error;

  error= NULL;
  if (!goa_provider_ensure_credentials_finish (provider, &expires_in, res, &error))
    {
      /* Set AttentionNeeded only if the error is an authorization error */
      if (is_authorization_error (error))
        {
          GoaAccount *account;
          account = goa_object_peek_account (data->object);
          if (!goa_account_get_attention_needed (account))
            {
              goa_account_set_attention_needed (account, TRUE);
              g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (account));
              g_message ("%s: Setting AttentionNeeded to TRUE because EnsureCredentials() failed with: %s (%s, %d)",
                         g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object)),
                         error->message, g_quark_to_string (error->domain), error->code);
            }
        }
      g_dbus_method_invocation_return_gerror (data->invocation, error);
      g_error_free (error);
    }
  else
    {
      GoaAccount *account;
      account = goa_object_peek_account (data->object);

      /* Clear AttentionNeeded flag if set */
      if (goa_account_get_attention_needed (account))
        {
          goa_account_set_attention_needed (account, FALSE);
          g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (account));
          g_message ("%s: Setting AttentionNeeded to FALSE because EnsureCredentials() succeded\n",
                     g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object)));
        }
      goa_account_complete_ensure_credentials (goa_object_peek_account (data->object),
                                               data->invocation,
                                               expires_in);
    }
  ensure_data_unref (data);
}
Пример #21
0
static gboolean
on_reset_tracking_id (EmerEventRecorderServer *server,
                      GDBusMethodInvocation   *invocation,
                      EmerDaemon              *daemon)
{
  g_autoptr(GError) error = NULL;

  if (!emer_daemon_reset_tracking_id (daemon, &error))
    {
      g_dbus_method_invocation_return_gerror (invocation, error);
      return TRUE;
    }

  emer_event_recorder_server_complete_reset_tracking_id (server, invocation);
  return TRUE;
}
Пример #22
0
static void
got_app_id_cb (GObject *source_object,
               GAsyncResult *res,
               gpointer user_data)
{
  GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (source_object);
  g_autoptr(GError) error = NULL;
  g_autofree char *app_id = NULL;
  PortalMethod portal_method = user_data;

  app_id = xdg_app_invocation_lookup_app_id_finish (invocation, res, &error);

  if (app_id == NULL)
    g_dbus_method_invocation_return_gerror (invocation, error);
  else
    portal_method (invocation, g_dbus_method_invocation_get_parameters (invocation), app_id);
}
Пример #23
0
static gboolean
handle_set_slave_bus_name (GdmDBusDisplay        *skeleton,
                           GDBusMethodInvocation *invocation,
                           const char            *bus_name,
                           GdmDisplay            *display)
{
    GError *error = NULL;

    if (gdm_display_set_slave_bus_name (display, bus_name, &error)) {
        gdm_dbus_display_complete_set_slave_bus_name (skeleton, invocation);
    } else {
        g_dbus_method_invocation_return_gerror (invocation, error);
        g_error_free (error);
    }

    return TRUE;
}
Пример #24
0
static gboolean
handle_remove_user_authorization (GdmDBusDisplay        *skeleton,
                                  GDBusMethodInvocation *invocation,
                                  const char            *username,
                                  GdmDisplay            *display)
{
    GError *error = NULL;

    if (gdm_display_remove_user_authorization (display, username, &error)) {
        gdm_dbus_display_complete_remove_user_authorization (skeleton, invocation);
    } else {
        g_dbus_method_invocation_return_gerror (invocation, error);
        g_error_free (error);
    }

    return TRUE;
}
Пример #25
0
static void
got_app_id_cb (GObject      *source_object,
               GAsyncResult *res,
               gpointer      user_data)
{
  GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (source_object);
  gboolean create = GPOINTER_TO_INT (user_data);
  g_autoptr(GError) error = NULL;
  char *app_id;

  app_id = xdp_invocation_lookup_app_id_finish (invocation, res, &error);

  if (app_id == NULL)
    g_dbus_method_invocation_return_gerror (invocation, error);
  else
    open_content_chooser (invocation, app_id, create);
}
Пример #26
0
static gboolean
common_setup (UDisksLinuxLogicalVolume           *volume,
              GDBusMethodInvocation              *invocation,
              GVariant                           *options,
              const gchar                        *auth_err_msg,
              UDisksLinuxLogicalVolumeObject    **object,
              UDisksDaemon                      **daemon,
              uid_t                              *out_uid,
              gid_t                              *out_gid)
{
  gboolean rc = FALSE;
  GError *error = NULL;

  *object = udisks_daemon_util_dup_object (volume, &error);
  if (*object == NULL)
    {
      g_dbus_method_invocation_take_error (invocation, error);
      goto out;
    }

  *daemon = udisks_linux_logical_volume_object_get_daemon (*object);

  if (!udisks_daemon_util_get_caller_uid_sync (*daemon,
                                               invocation,
                                               NULL /* GCancellable */,
                                               out_uid,
                                               out_gid,
                                               NULL,
                                               &error))
    {
      g_dbus_method_invocation_return_gerror (invocation, error);
      g_clear_error (&error);
      goto out;
    }

  /* Policy check. */
  UDISKS_DAEMON_CHECK_AUTHORIZATION (*daemon,
                                     UDISKS_OBJECT (*object),
                                     lvm2_policy_action_id,
                                     options,
                                     auth_err_msg,
                                     invocation);
  rc = TRUE;
 out:
  return rc;
}
static void
infinoted_plugin_dbus_check_acl(InfinotedPluginDbus* plugin,
                                InfinotedPluginDbusInvocation* invocation,
                                InfBrowser* browser,
                                const InfBrowserIter* iter)
{
  const gchar* account;
  GVariant* mask_variant;
  InfAclMask mask;
  InfAclMask out;
  GError* error;

  g_variant_get_child(invocation->parameters, 1, "&s", &account);
  g_variant_get_child(invocation->parameters, 2, "@as", &mask_variant);

  error = NULL;
  infinoted_plugin_dbus_mask_from_variant(&mask, mask_variant, &error);
  g_variant_unref(mask_variant);

  if(error != NULL)
  {
    g_dbus_method_invocation_return_gerror(invocation->invocation, error);
    g_error_free(error);
  }
  else
  {
    inf_browser_check_acl(
      browser,
      iter,
      inf_acl_account_id_from_string(account),
      &mask,
      &out
    );

    g_dbus_method_invocation_return_value(
      invocation->invocation,
      g_variant_new(
        "(@a{sb})",
        infinoted_plugin_dbus_perms_to_variant(&mask, &out)
      )
    );
  }

  infinoted_plugin_dbus_invocation_free(plugin, invocation);
}
Пример #28
0
/**
 * cd_sensor_set_options_cb:
 **/
static void
cd_sensor_set_options_cb (GObject *source_object,
			  GAsyncResult *res,
			  gpointer user_data)
{
	gboolean ret;
	CdSensor *sensor = CD_SENSOR (source_object);
	CdSensorPrivate *priv = GET_PRIVATE (sensor);
	GDBusMethodInvocation *invocation = (GDBusMethodInvocation *) user_data;
	g_autoptr(GError) error = NULL;

	/* get the result */
	ret = priv->desc->set_options_finish (sensor, res, &error);
	if (!ret) {
		g_dbus_method_invocation_return_gerror (invocation, error);
		return;
	}
	g_dbus_method_invocation_return_value (invocation, NULL);
}
Пример #29
0
/**
 * cd_sensor_get_spectrum_cb:
 **/
static void
cd_sensor_get_spectrum_cb (GObject *source_object,
			   GAsyncResult *res,
			   gpointer user_data)
{
	CdSensor *sensor = CD_SENSOR (source_object);
	CdSensorPrivate *priv = GET_PRIVATE (sensor);
	GDBusMethodInvocation *invocation = (GDBusMethodInvocation *) user_data;
	GVariant *result = NULL;
	GVariantBuilder data;
	guint i;
	g_autoptr(CdSpectrum) sp = NULL;
	g_autoptr(GError) error = NULL;

	/* set here to avoid every sensor doing this */
	cd_sensor_set_state (sensor, CD_SENSOR_STATE_IDLE);

	/* get the result */
	sp = priv->desc->get_spectrum_finish (sensor, res, &error);
	if (sp == NULL) {
		g_dbus_method_invocation_return_gerror (invocation, error);
		return;
	}

	/* build data array */
	g_variant_builder_init (&data, G_VARIANT_TYPE ("ad"));
	for (i = 0; i < cd_spectrum_get_size (sp); i++) {
		g_variant_builder_add (&data, "d",
				       cd_spectrum_get_value (sp, i));
	}

	/* return value */
	g_debug ("returning value %f, %f, [%u]",
		 cd_spectrum_get_start (sp),
		 cd_spectrum_get_end (sp),
		 cd_spectrum_get_size (sp));
	result = g_variant_new ("(ddad)",
				cd_spectrum_get_start (sp),
				cd_spectrum_get_end (sp),
				&data);
	g_dbus_method_invocation_return_value (invocation, result);
}
Пример #30
0
static gboolean
handle_install_bundle (FlatpakSystemHelper   *object,
                       GDBusMethodInvocation *invocation,
                       const gchar           *arg_bundle_path,
                       guint32                arg_flags,
                       GVariant              *arg_gpg_key)
{
  g_autoptr(FlatpakDir) system = dir_get_system ();
  g_autoptr(GFile) path = g_file_new_for_path (arg_bundle_path);
  g_autoptr(GError) error = NULL;
  g_autoptr(GBytes) gpg_data = NULL;
  g_autofree char *ref = NULL;

  g_debug ("InstallBundle %s %u %p", arg_bundle_path, arg_flags, arg_gpg_key);

  if (arg_flags != 0)
    {
      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                                             "Unsupported flags enabled: 0x%x", arg_flags);
      return TRUE;
    }

  if (!g_file_query_exists (path, NULL))
    {
      g_dbus_method_invocation_return_error (invocation, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
                                             "Bundle %s does not exist", arg_bundle_path);
      return TRUE;
    }

  if (g_variant_get_size (arg_gpg_key) > 0)
    gpg_data = g_variant_get_data_as_bytes (arg_gpg_key);

  if (!flatpak_dir_install_bundle (system, path, gpg_data, &ref, NULL, &error))
    {
      g_dbus_method_invocation_return_gerror  (invocation, error);
      return TRUE;
    }

  flatpak_system_helper_complete_install_bundle (object, invocation, ref);

  return TRUE;
}