/* < internal >
 * _g_dbus_method_invocation_new:
 * @sender: The bus name that invoked the method or %NULL if @connection is not a bus connection.
 * @object_path: The object path the method was invoked on.
 * @interface_name: The name of the D-Bus interface the method was invoked on.
 * @method_name: The name of the method that was invoked.
 * @method_info: Information about the method call or %NULL.
 * @connection: The #GDBusConnection the method was invoked on.
 * @message: The D-Bus message as a #GDBusMessage.
 * @parameters: The parameters as a #GVariant tuple.
 * @user_data: The @user_data #gpointer passed to g_dbus_connection_register_object().
 *
 * Creates a new #GDBusMethodInvocation object.
 *
 * Returns: A #GDBusMethodInvocation. Free with g_object_unref().
 *
 * Since: 2.26
 */
GDBusMethodInvocation *
_g_dbus_method_invocation_new (const gchar           *sender,
                               const gchar           *object_path,
                               const gchar           *interface_name,
                               const gchar           *method_name,
                               const GDBusMethodInfo *method_info,
                               GDBusConnection       *connection,
                               GDBusMessage          *message,
                               GVariant              *parameters,
                               gpointer               user_data)
{
  GDBusMethodInvocation *invocation;

  g_return_val_if_fail (sender == NULL || g_dbus_is_name (sender), NULL);
  g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
  g_return_val_if_fail (interface_name == NULL || g_dbus_is_interface_name (interface_name), NULL);
  g_return_val_if_fail (g_dbus_is_member_name (method_name), NULL);
  g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
  g_return_val_if_fail (G_IS_DBUS_MESSAGE (message), NULL);
  g_return_val_if_fail (g_variant_is_of_type (parameters, G_VARIANT_TYPE_TUPLE), NULL);

  invocation = G_DBUS_METHOD_INVOCATION (g_object_new (G_TYPE_DBUS_METHOD_INVOCATION, NULL));
  invocation->sender = g_strdup (sender);
  invocation->object_path = g_strdup (object_path);
  invocation->interface_name = g_strdup (interface_name);
  invocation->method_name = g_strdup (method_name);
  invocation->method_info = g_dbus_method_info_ref ((GDBusMethodInfo *)method_info);
  invocation->connection = g_object_ref (connection);
  invocation->message = g_object_ref (message);
  invocation->parameters = g_variant_ref (parameters);
  invocation->user_data = user_data;

  return invocation;
}
Exemple #2
0
static void
photos_search_provider_fetch_ids_executed (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  GApplication *app;
  GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (user_data);
  PhotosFetchIdsJob *job = PHOTOS_FETCH_IDS_JOB (source_object);
  GError *error = NULL;
  GVariant *parameters;
  const gchar *const *ids;

  app = g_application_get_default ();
  g_application_release (app);

  ids = photos_fetch_ids_job_finish (job, res, &error);
  if (error != NULL)
    {
      g_dbus_method_invocation_take_error (invocation, error);
      goto out;
    }

  parameters = g_variant_new ("(^as)", ids);
  g_dbus_method_invocation_return_value (invocation, parameters);

 out:
  g_object_unref (invocation);
}
static void
photos_thumbnailer_handle_generate_thumbnail_generate_thumbnail (GObject *source_object,
                                                                 GAsyncResult *res,
                                                                 gpointer user_data)
{
  PhotosThumbnailer *self = PHOTOS_THUMBNAILER (source_object);
  g_autoptr (GDBusMethodInvocation) invocation = G_DBUS_METHOD_INVOCATION (user_data);

  {
    g_autoptr (GError) error = NULL;

    if (!photos_thumbnailer_generate_thumbnail_finish (self, res, &error))
      {
        g_dbus_method_invocation_take_error (invocation, g_steal_pointer (&error));
        goto out;
      }
  }

  photos_thumbnailer_dbus_complete_generate_thumbnail (self->skeleton, invocation);

 out:
  photos_debug (PHOTOS_DEBUG_THUMBNAILER, "Completed GenerateThumbnail");
  g_application_release (G_APPLICATION (self));
  g_hash_table_remove (self->cancellables, invocation);
}
static void
gom_application_insert_shared_content_cb (GObject *source,
                                          GAsyncResult *res,
                                          gpointer user_data)
{
  GomApplication *self;
  GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (user_data);
  GError *error;

  self = GOM_APPLICATION (g_application_get_default ());
  g_application_release (G_APPLICATION (self));

  error = NULL;
  if (!gom_miner_insert_shared_content_finish (GOM_MINER (source), res, &error))
    {
      g_printerr ("Failed to insert shared content: %s\n", error->message);
      g_dbus_method_invocation_take_error (invocation, error);
      goto out;
    }

  gom_dbus_complete_insert_shared_content (self->skeleton, invocation);

 out:
  g_object_unref (invocation);
}
static void
gom_application_process_queue (GomApplication *self)
{
  GDBusMethodInvocation *invocation = NULL;
  const gchar **index_types;

  if (self->refreshing)
    goto out;

  if (g_queue_is_empty (self->queue))
    goto out;

  invocation = G_DBUS_METHOD_INVOCATION (g_queue_pop_head (self->queue));
  index_types = g_object_get_data (G_OBJECT (invocation), "index-types");
  gom_miner_set_index_types (self->miner, index_types);

  self->refreshing = TRUE;
  g_application_hold (G_APPLICATION (self));
  gom_miner_refresh_db_async (self->miner,
                              self->cancellable,
                              gom_application_refresh_db_cb,
                              g_object_ref (invocation));

 out:
  g_clear_object (&invocation);
}
static void
la_handler_service_handle_register_finish (GObject      *object,
                                           GAsyncResult *res,
                                           gpointer      user_data)
{
  GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (user_data);
  LAHandlerService      *service;
  NSMConsumer           *nsm_consumer = NSM_CONSUMER (object);
  GError                *error = NULL;
  gint                   error_code;

  g_return_if_fail (IS_NSM_CONSUMER (nsm_consumer));
  g_return_if_fail (G_IS_ASYNC_RESULT (res));
  g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation));

  /* finish registering the shutdown client */
  nsm_consumer_call_register_shutdown_client_finish (nsm_consumer, &error_code, res,
                                                     &error);
  if (error != NULL)
    {
      DLT_LOG (la_handler_context, DLT_LOG_ERROR,
               DLT_STRING ("Failed to register a shutdown consumer:"),
               DLT_STRING (error->message));
      g_error_free (error);
    }

  /* retrieve the LAHandlerService from the invocation object */
  service = g_object_get_data (G_OBJECT (invocation), "la-handler-service");

  /* notify the caller that we have handled the registration request */
  la_handler_complete_register (service->interface, invocation);
}
static void
g_dbus_method_invocation_finalize (GObject *object)
{
  GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (object);

  g_free (invocation->sender);
  g_free (invocation->object_path);
  g_free (invocation->interface_name);
  g_free (invocation->method_name);
  g_object_unref (invocation->connection);
  g_object_unref (invocation->message);
  g_variant_unref (invocation->parameters);

  G_OBJECT_CLASS (g_dbus_method_invocation_parent_class)->finalize (object);
}
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);
}
Exemple #9
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);
}
Exemple #10
0
static void
photos_search_provider_fetch_metas_executed (GList *metas, gpointer user_data)
{
  PhotosSearchProvider *self;
  GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (user_data);
  GList *l;
  const gchar *const *identifiers;

  self = PHOTOS_SEARCH_PROVIDER (g_object_get_data (G_OBJECT (invocation), "self"));
  identifiers = (const gchar *const *) g_object_get_data (G_OBJECT (invocation), "identifiers");

  for (l = metas; l != NULL; l = l->next)
    {
      PhotosFetchMeta *copy;
      PhotosFetchMeta *meta = (PhotosFetchMeta *) l->data;

      copy = photos_fetch_meta_copy (meta);
      g_hash_table_insert (self->cache, copy->id, copy);
    }

  photos_search_provider_return_metas_from_cache (self, identifiers, invocation);
}