1 /* vim:set et sts=4: */
2 /* ibus - The Input Bus
3 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
4 * Copyright (C) 2008-2010 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * @short_description: Base proxy object.
26 * An IBusProxy is the base of all proxy objects,
27 * which communicate the corresponding #IBusServices on the other end of IBusConnection.
28 * For example, IBus clients (such as editors, web browsers) invoke the proxy object,
29 * IBusInputContext to communicate with the InputContext service of the ibus-daemon.
31 * Almost all services have corresponding proxies, except very simple services.
33 #ifndef __IBUS_PROXY_H_
34 #define __IBUS_PROXY_H_
36 #include "ibusobject.h"
37 #include "ibusconnection.h"
38 #include "ibusmessage.h"
44 /* define GOBJECT macros */
45 #define IBUS_TYPE_PROXY \
46 (ibus_proxy_get_type ())
47 #define IBUS_PROXY(obj) \
48 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_PROXY, IBusProxy))
49 #define IBUS_PROXY_CLASS(klass) \
50 (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_PROXY, IBusProxyClass))
51 #define IBUS_IS_PROXY(obj) \
52 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_PROXY))
53 #define IBUS_IS_PROXY_CLASS(klass) \
54 (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_PROXY))
55 #define IBUS_PROXY_GET_CLASS(obj) \
56 (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_PROXY, IBusProxyClass))
60 typedef struct _IBusProxy IBusProxy;
61 typedef struct _IBusProxyClass IBusProxyClass;
66 * An opaque data type representing an IBusProxy.
70 /* instance members */
73 struct _IBusProxyClass {
74 IBusObjectClass parent;
77 gboolean (* ibus_signal) (IBusProxy *proxy,
78 IBusMessage *message);
84 GType ibus_proxy_get_type (void);
88 * @name: The service name of proxy object.
89 * @path: The path of proxy object.
90 * @connection: An IBusConnection.
91 * @returns: A newly allocated IBusProxy instance.
93 * New an IBusProxy instance.
94 * Property IBusProxy:name is set as @name, and
95 * IBusProxy:path is set as @path.
97 IBusProxy *ibus_proxy_new (const gchar *name,
99 IBusConnection *connection);
103 * @proxy: An IBusProxy.
104 * @message: The IBusMessage to be sent.
105 * @returns: TRUE if succeed; FALSE otherwise.
107 * Send an #IBusMessage to the corresponding service.
109 * @see_also ibus_proxy_call(), ibus_proxy_send_with_reply(), ibus_proxy_send_with_reply_and_block().
111 gboolean ibus_proxy_send (IBusProxy *proxy,
112 IBusMessage *message);
116 * @proxy: An IBusProxy.
117 * @method: The method to be called.
118 * @first_arg_type: Type of first argument.
119 * @...: Rest of arguments, NULL to mark the end.
120 * @returns: TRUE if succeed; FALSE otherwise.
122 * Call a method of the corresponding service.
124 * @see_also ibus_proxy_send(), ibus_proxy_call_with_reply(), ibus_proxy_call_with_reply_and_block().
126 gboolean ibus_proxy_call (IBusProxy *proxy,
128 GType first_arg_type,
132 * ibus_proxy_call_with_reply:
133 * @proxy: An IBusProxy.
134 * @method: The method to be called.
135 * @pending: Return location of a IBusPendingCall object, or NULL if connection is disconnected.
136 * @timeout_milliseconds: Time out in milliseconds.
137 * @error: Returned error is stored here; NULL to ignore error.
138 * @first_arg_type: Type of first argument.
139 * @...: Rest of arguments, NULL to mark the end.
140 * @returns: TRUE if succeed; FALSE otherwise.
142 * Call a method of the corresponding service, and returns an IBusPendingCall used to receive a reply to the message.
143 * This function calls ibus_connection_send_with_reply() to do the actual sending.
145 * @see_also: ibus_connection_send_with_reply(), ibus_proxy_call(),
146 * ibus_proxy_send_with_reply(), ibus_proxy_call_with_reply_and_block().
148 gboolean ibus_proxy_call_with_reply (IBusProxy *proxy,
150 IBusPendingCall **pending,
151 gint timeout_milliseconds,
153 GType first_arg_type,
157 * ibus_proxy_call_with_reply_and_block:
158 * @proxy: An IBusProxy.
159 * @method: The method to be called.
160 * @timeout_milliseconds: Time out in milliseconds.
161 * @error: Returned error is stored here; NULL to ignore error.
162 * @first_arg_type: Type of first argument.
163 * @...: Rest of arguments, NULL to mark the end.
164 * @returns: An IBusMessage that is the reply or NULL with an error code if the function fails.
166 * Call a method of the corresponding service and blocks a certain time period while waiting for
167 * an IBusMessage as reply.
168 * If the IBusMessage is not NULL, it calls ibus_connection_send_with_reply_and_block() to do the
171 * @see_also: ibus_connection_send_with_reply_and_block(), ibus_proxy_call(),
172 * ibus_proxy_send_with_reply(), ibus_proxy_call_with_reply_and_block().
174 IBusMessage *ibus_proxy_call_with_reply_and_block
177 gint timeout_milliseconds,
179 GType first_arg_type,
183 * ibus_proxy_send_with_reply:
184 * @proxy: An IBusProxy.
185 * @message: The IBusMessage to be sent.
186 * @pending: Return location of a IBusPendingCall object, or NULL if connection is disconnected.
187 * @timeout_milliseconds: Time out in milliseconds.
188 * @returns: TRUE if succeed; FALSE otherwise.
190 * Send an IBusMessage to the corresponding service and returns
191 * an IBusPendingCall used to receive a reply to the message.
192 * This function calls ibus_connection_send_with_reply() to do the actual sending.
194 * @see_also: ibus_connection_send_with_reply(), ibus_proxy_send(),
195 * ibus_proxy_call_with_reply(), ibus_proxy_send_with_reply_and_block().
197 gboolean ibus_proxy_send_with_reply (IBusProxy *proxy,
198 IBusMessage *message,
199 IBusPendingCall **pending,
200 gint timeout_milliseconds);
203 * ibus_proxy_send_with_reply_and_block:
204 * @proxy: An IBusProxy.
205 * @message: The IBusMessage to be sent.
206 * @returns: An IBusMessage that is the reply or NULL with an error code if the function fails.
208 * Send an IBusMessage to the corresponding service and blocks a certain time period while waiting for
209 * an IBusMessage as reply.
210 * If the IBusMessage is not NULL, it calls ibus_connection_send_with_reply_and_block() to do the
213 * @see_also: ibus_connection_send_with_reply_and_block(), ibus_proxy_send(), ibus_proxy_send_with_reply(),
214 * ibus_proxy_call_with_reply_and_block().
216 IBusMessage *ibus_proxy_send_with_reply_and_block
218 IBusMessage *message);
221 * ibus_proxy_handle_signal:
222 * @proxy: An IBusProxy.
223 * @message: The IBusMessage to be sent.
224 * @returns: TRUE if succeed; FALSE otherwise.
226 * Handle a signal by emitting IBusProxy::ibus-signal.
228 * If signal name is <constant>NameOwnerChanged</constant>
229 * and the service name is identical to the old name, then
230 * @proxy will be destroyed by ibus_object_destroy () and FALSE is returned.
231 * Otherwise TRUE is returned.
233 * Note that if the path of of message is not identical to the IBusProxy:path
234 * this function will not emit IBusProxy::ibus-signal.
237 gboolean ibus_proxy_handle_signal (IBusProxy *proxy,
238 IBusMessage *message);
241 * ibus_proxy_get_name:
242 * @proxy: An IBusProxy.
243 * @returns: The service name of the proxy object.
245 * Get the service name of a proxy object.
247 const gchar *ibus_proxy_get_name (IBusProxy *proxy);
250 * ibus_proxy_get_unique_name:
251 * @proxy: An IBusProxy.
252 * @returns: The service name of the proxy object.
254 * Get the unique name of the proxy object.
256 const gchar *ibus_proxy_get_unique_name (IBusProxy *proxy);
259 * ibus_proxy_get_path:
260 * @proxy: An IBusProxy.
261 * @returns: The path of proxy object.
263 * Get the path of a proxy object.
265 const gchar *ibus_proxy_get_path (IBusProxy *proxy);
268 * ibus_proxy_get_interface:
269 * @proxy: An IBusProxy.
270 * @returns: The service name of the proxy object.
272 * Get interface of a proxy object.
274 const gchar *ibus_proxy_get_interface (IBusProxy *proxy);
277 * ibus_proxy_get_connection:
278 * @proxy: An IBusProxy.
279 * @returns: (transfer none): The connection of the proxy object.
281 * Get the connection of a proxy object.
283 IBusConnection *ibus_proxy_get_connection (IBusProxy *proxy);