Add Ctrl+space customization.
[platform/upstream/ibus.git] / src / ibusservice.h
1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
3 /* ibus - The Input Bus
4  * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
5  * Copyright (C) 2008-2010 Red Hat, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
25 #endif
26
27 /**
28  * SECTION: ibusservice
29  * @short_description: IBus service back-end.
30  * @stability: Stable
31  *
32  * An IBusService is a base class for services.
33  */
34
35 #ifndef __IBUS_SERVICE_H_
36 #define __IBUS_SERVICE_H_
37
38 #include <gio/gio.h>
39 #include "ibusobject.h"
40
41 /*
42  * Type macros.
43  */
44
45 /* define GOBJECT macros */
46 #define IBUS_TYPE_SERVICE             \
47     (ibus_service_get_type ())
48 #define IBUS_SERVICE(obj)             \
49     (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_SERVICE, IBusService))
50 #define IBUS_SERVICE_CLASS(klass)     \
51     (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_SERVICE, IBusServiceClass))
52 #define IBUS_IS_SERVICE(obj)          \
53     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_SERVICE))
54 #define IBUS_IS_SERVICE_CLASS(klass)  \
55     (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_SERVICE))
56 #define IBUS_SERVICE_GET_CLASS(obj)   \
57     (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_SERVICE, IBusServiceClass))
58
59 G_BEGIN_DECLS
60
61 typedef struct _IBusService IBusService;
62 typedef struct _IBusServiceClass IBusServiceClass;
63 typedef struct _IBusServicePrivate IBusServicePrivate;
64
65 /**
66  * IBusService:
67  *
68  * An opaque data type representing an IBusService.
69  */
70 struct _IBusService {
71     /*< private >*/
72     IBusObject parent;
73     IBusServicePrivate *priv;
74 };
75
76 struct _IBusServiceClass {
77     /*< private >*/
78     IBusObjectClass parent;
79
80     /*< public >*/
81     /* virtual functions */
82     void        (* service_method_call)
83                                     (IBusService        *service,
84                                      GDBusConnection    *connection,
85                                      const gchar        *sender,
86                                      const gchar        *object_path,
87                                      const gchar        *interface_name,
88                                      const gchar        *method_name,
89                                      GVariant           *parameters,
90                                      GDBusMethodInvocation
91                                                         *invocation);
92     GVariant *  (* service_get_property)
93                                     (IBusService        *service,
94                                      GDBusConnection    *connection,
95                                      const gchar        *sender,
96                                      const gchar        *object_path,
97                                      const gchar        *interface_name,
98                                      const gchar        *property_name,
99                                      GError            **error);
100     gboolean    (* service_set_property)
101                                     (IBusService        *service,
102                                      GDBusConnection    *connection,
103                                      const gchar        *sender,
104                                      const gchar        *object_path,
105                                      const gchar        *interface_name,
106                                      const gchar        *property_name,
107                                      GVariant           *value,
108                                      GError            **error);
109     /*< private >*/
110     GArray *interfaces;
111
112     /* padding */
113     gpointer pdummy[4];
114 };
115
116
117 GType            ibus_service_get_type          (void);
118
119 /**
120  * ibus_service_new:
121  * @path: Object path.
122  * @returns: A newly allocated IBusService
123  *
124  * New an IBusService.
125  */
126 IBusService     *ibus_service_new               (GDBusConnection    *connection,
127                                                  const gchar        *path);
128 /**
129  * ibus_service_get_object_path:
130  * @service: An IBusService.
131  * @returns: The object path of @service
132  *
133  * Returns the object path of an IBusService.
134  */
135 const gchar     *ibus_service_get_object_path   (IBusService        *service);
136
137 /**
138  * ibus_service_get_connection:
139  * @service: An IBusService.
140  * @returns: (transfer none): A #GDBusConnection of an #IBusService instance.
141  *
142  * Returns a connections.
143  */
144 GDBusConnection *ibus_service_get_connection    (IBusService        *service);
145
146 /**
147  * ibus_service_register:
148  * @service: An IBusService.
149  * @connection: A GDBusConnection the service will be registered to.
150  * @error: Return location for error or NULL.
151  * @returns: TRUE if the service was registered, FALSE otherwise.
152  *
153  * Registers service to a connection.
154  */
155 gboolean         ibus_service_register          (IBusService        *service,
156                                                  GDBusConnection    *connection,
157                                                  GError            **error);
158 /**
159  * ibus_service_unregister:
160  * @service: An IBusService.
161  * @connection: A GDBusConnection the service was registered with.
162  *
163  * Unregisters service from a connection.
164  */
165 void             ibus_service_unregister        (IBusService        *service,
166                                                  GDBusConnection    *connection);
167
168
169
170 /**
171  * ibus_service_send_signal:
172  * @service: An IBusService.
173  * @interface: The interface the signal is emitted from.
174  * @name: Name of the signal.
175  * @first_arg_type: Type of first argument.
176  * @...: Rest of arguments, NULL to mark the end.
177  * @returns: TRUE if succeed; FALSE otherwise.
178  *
179  * Send signal to all the IBusConnections of an IBusService.
180  *
181  * @see_also: g_dbus_connection_emit_signal()
182  */
183 gboolean         ibus_service_emit_signal       (IBusService        *service,
184                                                  const gchar        *dest_bus_name,
185                                                  const gchar        *interface_name,
186                                                  const gchar        *signal_name,
187                                                  GVariant           *parameters,
188                                                  GError            **error);
189 /**
190  * ibus_service_class_add_interfaces:
191  * @klass: An IBusServiceClass.
192  * @xml_data: The introspection xml data.
193  *
194  * Set the interface introspection information with the service class.
195  */
196 gboolean         ibus_service_class_add_interfaces
197                                                 (IBusServiceClass   *klass,
198                                                  const gchar        *xml_data);
199
200
201 G_END_DECLS
202 #endif
203