Blame gio/gremoteactiongroup.c

Packit ae235b
/*
Packit ae235b
 * Copyright © 2010 Codethink Limited
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General
Packit ae235b
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 *
Packit ae235b
 * Authors: Ryan Lortie <desrt@desrt.ca>
Packit ae235b
 */
Packit ae235b
Packit ae235b
#include "config.h"
Packit ae235b
Packit ae235b
#include "gsimpleaction.h"
Packit ae235b
#include "gactiongroup.h"
Packit ae235b
#include "gactionmap.h"
Packit ae235b
#include "gaction.h"
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * SECTION:gremoteactiongroup
Packit ae235b
 * @title: GRemoteActionGroup
Packit ae235b
 * @short_description: A GActionGroup that interacts with other processes
Packit ae235b
 * @include: gio/gio.h
Packit ae235b
 *
Packit ae235b
 * The GRemoteActionGroup interface is implemented by #GActionGroup
Packit ae235b
 * instances that either transmit action invocations to other processes
Packit ae235b
 * or receive action invocations in the local process from other
Packit ae235b
 * processes.
Packit ae235b
 *
Packit ae235b
 * The interface has `_full` variants of the two
Packit ae235b
 * methods on #GActionGroup used to activate actions:
Packit ae235b
 * g_action_group_activate_action() and
Packit ae235b
 * g_action_group_change_action_state(). These variants allow a
Packit ae235b
 * "platform data" #GVariant to be specified: a dictionary providing
Packit ae235b
 * context for the action invocation (for example: timestamps, startup
Packit ae235b
 * notification IDs, etc).
Packit ae235b
 *
Packit ae235b
 * #GDBusActionGroup implements #GRemoteActionGroup.  This provides a
Packit ae235b
 * mechanism to send platform data for action invocations over D-Bus.
Packit ae235b
 *
Packit ae235b
 * Additionally, g_dbus_connection_export_action_group() will check if
Packit ae235b
 * the exported #GActionGroup implements #GRemoteActionGroup and use the
Packit ae235b
 * `_full` variants of the calls if available.  This
Packit ae235b
 * provides a mechanism by which to receive platform data for action
Packit ae235b
 * invocations that arrive by way of D-Bus.
Packit ae235b
 *
Packit ae235b
 * Since: 2.32
Packit ae235b
 **/
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GRemoteActionGroup:
Packit ae235b
 *
Packit ae235b
 * #GRemoteActionGroup is an opaque data structure and can only be accessed
Packit ae235b
 * using the following functions.
Packit ae235b
 **/
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GRemoteActionGroupInterface:
Packit ae235b
 * @activate_action_full: the virtual function pointer for g_remote_action_group_activate_action_full()
Packit ae235b
 * @change_action_state_full: the virtual function pointer for g_remote_action_group_change_action_state_full()
Packit ae235b
 *
Packit ae235b
 * The virtual function table for #GRemoteActionGroup.
Packit ae235b
 *
Packit ae235b
 * Since: 2.32
Packit ae235b
 **/
Packit ae235b
Packit ae235b
#include "config.h"
Packit ae235b
Packit ae235b
#include "gremoteactiongroup.h"
Packit ae235b
Packit ae235b
G_DEFINE_INTERFACE (GRemoteActionGroup, g_remote_action_group, G_TYPE_ACTION_GROUP)
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_remote_action_group_default_init (GRemoteActionGroupInterface *iface)
Packit ae235b
{
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_remote_action_group_activate_action_full:
Packit ae235b
 * @remote: a #GDBusActionGroup
Packit ae235b
 * @action_name: the name of the action to activate
Packit ae235b
 * @parameter: (nullable): the optional parameter to the activation
Packit ae235b
 * @platform_data: the platform data to send
Packit ae235b
 *
Packit ae235b
 * Activates the remote action.
Packit ae235b
 *
Packit ae235b
 * This is the same as g_action_group_activate_action() except that it
Packit ae235b
 * allows for provision of "platform data" to be sent along with the
Packit ae235b
 * activation request.  This typically contains details such as the user
Packit ae235b
 * interaction timestamp or startup notification information.
Packit ae235b
 *
Packit ae235b
 * @platform_data must be non-%NULL and must have the type
Packit ae235b
 * %G_VARIANT_TYPE_VARDICT.  If it is floating, it will be consumed.
Packit ae235b
 *
Packit ae235b
 * Since: 2.32
Packit ae235b
 **/
Packit ae235b
void
Packit ae235b
g_remote_action_group_activate_action_full (GRemoteActionGroup *remote,
Packit ae235b
                                            const gchar        *action_name,
Packit ae235b
                                            GVariant           *parameter,
Packit ae235b
                                            GVariant           *platform_data)
Packit ae235b
{
Packit ae235b
  G_REMOTE_ACTION_GROUP_GET_IFACE (remote)
Packit ae235b
    ->activate_action_full (remote, action_name, parameter, platform_data);
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_remote_action_group_change_action_state_full:
Packit ae235b
 * @remote: a #GRemoteActionGroup
Packit ae235b
 * @action_name: the name of the action to change the state of
Packit ae235b
 * @value: the new requested value for the state
Packit ae235b
 * @platform_data: the platform data to send
Packit ae235b
 *
Packit ae235b
 * Changes the state of a remote action.
Packit ae235b
 *
Packit ae235b
 * This is the same as g_action_group_change_action_state() except that
Packit ae235b
 * it allows for provision of "platform data" to be sent along with the
Packit ae235b
 * state change request.  This typically contains details such as the
Packit ae235b
 * user interaction timestamp or startup notification information.
Packit ae235b
 *
Packit ae235b
 * @platform_data must be non-%NULL and must have the type
Packit ae235b
 * %G_VARIANT_TYPE_VARDICT.  If it is floating, it will be consumed.
Packit ae235b
 *
Packit ae235b
 * Since: 2.32
Packit ae235b
 **/
Packit ae235b
void
Packit ae235b
g_remote_action_group_change_action_state_full (GRemoteActionGroup *remote,
Packit ae235b
                                                const gchar        *action_name,
Packit ae235b
                                                GVariant           *value,
Packit ae235b
                                                GVariant           *platform_data)
Packit ae235b
{
Packit ae235b
  G_REMOTE_ACTION_GROUP_GET_IFACE (remote)
Packit ae235b
    ->change_action_state_full (remote, action_name, value, platform_data);
Packit ae235b
}