Tizen 2.1 base
[platform/upstream/glib2.0.git] / gio / gremoteactiongroup.c
1 /*
2  * Copyright © 2010 Codethink Limited
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published
6  * by the Free Software Foundation; either version 2 of the licence or (at
7  * your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General
15  * Public License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  * Authors: Ryan Lortie <desrt@desrt.ca>
20  */
21
22 #include "config.h"
23
24 #include "gsimpleaction.h"
25 #include "gactiongroup.h"
26 #include "gactionmap.h"
27 #include "gaction.h"
28
29 /**
30  * SECTION:gremoteactiongroup
31  * @title: GRemoteActionGroup
32  * @short_description: a #GActionGroup that interacts with other processes
33  *
34  * The GRemoteActionGroup interface is implemented by #GActionGroup
35  * instances that either transmit action invocations to other processes
36  * or receive action invocations in the local process from other
37  * processes.
38  *
39  * The interface has <literal>_full</literal> variants of the two
40  * methods on #GActionGroup used to activate actions:
41  * g_action_group_activate_action() and
42  * g_action_group_change_action_state().  These variants allow a
43  * "platform data" #GVariant to be specified: a dictionary providing
44  * context for the action invocation (for example: timestamps, startup
45  * notification IDs, etc).
46  *
47  * #GDBusActionGroup implements #GRemoteActionGroup.  This provides a
48  * mechanism to send platform data for action invocations over D-Bus.
49  *
50  * Additionally, g_dbus_connection_export_action_group() will check if
51  * the exported #GActionGroup implements #GRemoteActionGroup and use the
52  * <literal>_full</literal> variants of the calls if available.  This
53  * provides a mechanism by which to receive platform data for action
54  * invocations that arrive by way of D-Bus.
55  *
56  * Since: 2.32
57  **/
58
59 /**
60  * GRemoteActionGroupInterface:
61  * @activate_action_full: the virtual function pointer for g_remote_action_group_activate_action_full()
62  * @change_action_state_full: the virtual function pointer for g_remote_action_group_change_action_state_full()
63  *
64  * The virtual function table for #GRemoteActionGroup.
65  *
66  * Since: 2.32
67  **/
68
69 #include "config.h"
70
71 #include "gremoteactiongroup.h"
72
73 G_DEFINE_INTERFACE (GRemoteActionGroup, g_remote_action_group, G_TYPE_ACTION_GROUP)
74
75 static void
76 g_remote_action_group_default_init (GRemoteActionGroupInterface *iface)
77 {
78 }
79
80 /**
81  * g_remote_action_group_activate_action_full:
82  * @remote: a #GDBusActionGroup
83  * @action_name: the name of the action to activate
84  * @parameter: (allow-none): the optional parameter to the activation
85  * @platform_data: the platform data to send
86  *
87  * Activates the remote action.
88  *
89  * This is the same as g_action_group_activate_action() except that it
90  * allows for provision of "platform data" to be sent along with the
91  * activation request.  This typically contains details such as the user
92  * interaction timestamp or startup notification information.
93  *
94  * @platform_data must be non-%NULL and must have the type
95  * %G_VARIANT_TYPE_VARDICT.  If it is floating, it will be consumed.
96  *
97  * Since: 2.32
98  **/
99 void
100 g_remote_action_group_activate_action_full (GRemoteActionGroup *remote,
101                                             const gchar        *action_name,
102                                             GVariant           *parameter,
103                                             GVariant           *platform_data)
104 {
105   G_REMOTE_ACTION_GROUP_GET_IFACE (remote)
106     ->activate_action_full (remote, action_name, parameter, platform_data);
107 }
108
109 /**
110  * g_remote_action_group_change_action_state_full:
111  * @remote: a #GRemoteActionGroup
112  * @action_name: the name of the action to change the state of
113  * @value: the new requested value for the state
114  * @platform_data: the platform data to send
115  *
116  * Changes the state of a remote action.
117  *
118  * This is the same as g_action_group_change_action_state() except that
119  * it allows for provision of "platform data" to be sent along with the
120  * state change request.  This typically contains details such as the
121  * user interaction timestamp or startup notification information.
122  *
123  * @platform_data must be non-%NULL and must have the type
124  * %G_VARIANT_TYPE_VARDICT.  If it is floating, it will be consumed.
125  *
126  * Since: 2.32
127  **/
128 void
129 g_remote_action_group_change_action_state_full (GRemoteActionGroup *remote,
130                                                 const gchar        *action_name,
131                                                 GVariant           *value,
132                                                 GVariant           *platform_data)
133 {
134   G_REMOTE_ACTION_GROUP_GET_IFACE (remote)
135     ->change_action_state_full (remote, action_name, value, platform_data);
136 }