return reply;
}
-gboolean
-ibus_connection_call (IBusConnection *connection,
- const gchar *name,
- const gchar *path,
- const gchar *interface,
- const gchar *member,
- IBusError **error,
- GType first_arg_type,
- ...)
+static IBusMessage *
+ibus_connection_call_with_reply_valist (IBusConnection *connection,
+ const gchar *name,
+ const gchar *path,
+ const gchar *interface,
+ const gchar *member,
+ IBusError **error,
+ GType first_arg_type,
+ va_list va_args)
{
g_assert (IBUS_IS_CONNECTION (connection));
g_assert (name != NULL);
IBusMessage *message, *reply;
IBusError *tmp_error;
- va_list args;
GType type;
gboolean retval;
message = ibus_message_new_method_call (name, path, interface, member);
- va_start (args, first_arg_type);
-
- ibus_message_append_args_valist (message, first_arg_type, args);
-
- va_end (args);
+ ibus_message_append_args_valist (message, first_arg_type, va_args);
reply = ibus_connection_send_with_reply_and_block (
connection,
ibus_message_unref (message);
if (reply == NULL) {
- return FALSE;
+ return NULL;
}
if ((tmp_error = ibus_error_new_from_message (reply)) != NULL) {
ibus_error_free (tmp_error);
}
ibus_message_unref (reply);
- return FALSE;
+ return NULL;
}
- va_start (args, first_arg_type);
+ return reply;
+}
+
+IBusMessage *
+ibus_connection_call_with_reply (IBusConnection *connection,
+ const gchar *name,
+ const gchar *path,
+ const gchar *interface,
+ const gchar *member,
+ IBusError **error,
+ GType first_arg_type,
+ ...)
+{
+ IBusMessage *reply;
+ va_list va_args;
- type = first_arg_type;
+ va_start (va_args, first_arg_type);
+ reply = ibus_connection_call_with_reply_valist (
+ connection, name, path, interface, member, error,
+ first_arg_type, va_args);
+ va_end (va_args);
- while (type != G_TYPE_INVALID) {
- va_arg (args, gpointer);
- type = va_arg (args, GType);
- }
- type = va_arg (args, GType);
+ return reply;
+}
- if (type != G_TYPE_INVALID) {
- retval = ibus_message_get_args_valist (reply, error, type, args);
- }
- else {
- retval = TRUE;
- }
+gboolean
+ibus_connection_call (IBusConnection *connection,
+ const gchar *name,
+ const gchar *path,
+ const gchar *interface,
+ const gchar *member,
+ IBusError **error,
+ GType first_arg_type,
+ ...)
+{
+ IBusMessage *reply;
+ va_list va_args;
- va_end (args);
- ibus_message_unref (reply);
+ va_start (va_args, first_arg_type);
+ reply = ibus_connection_call_with_reply_valist (
+ connection, name, path, interface, member, error,
+ first_arg_type, va_args);
+ va_end (va_args);
- return retval;
+ if (reply) {
+ ibus_message_unref (reply);
+ return TRUE;
+ }
+
+ return FALSE;
}
void
* @...: Rest of arguments, NULL to mark the end.
* @returns: TRUE if succeed; FALSE otherwise.
*
- * Invoke a member function by sending an IBusMessage.
+ * Invoke a member function by sending an IBusMessage. This method does not
+ * support reply message, use ibus_connection_call_with_reply instead.
*
* @see_also: ibus_connection_send_valist().
*/
...);
/**
+ * ibus_connection_call_with_reply:
+ * @connection: An IBusConnection.
+ * @name: Name of the signal.
+ * @path: The path to the object emitting the signal.
+ * @interface: The interface the signal is emitted from.
+ * @member: The name of the member function to be called.
+ * @error: Returned error is stored here; NULL to ignore error.
+ * @first_arg_type: Type of first argument.
+ * @...: Rest of arguments, NULL to mark the end.
+ * @returns: Reply message, or NULL when fail. The returned message must be
+ * freed with ibus_message_unref().
+ *
+ * Invoke a member function by sending an IBusMessage.
+ *
+ * @see_also: ibus_connection_send_valist().
+ */
+IBusMessage *ibus_connection_call_with_reply (IBusConnection *connection,
+ const gchar *name,
+ const gchar *path,
+ const gchar *interface,
+ const gchar *member,
+ IBusError **error,
+ GType first_arg_type,
+ ...);
+
+/**
* ibus_connection_flush:
* @connection: An IBusConnection.
*
G_END_DECLS
#endif
-
"AddMatch",
&error,
G_TYPE_STRING, &rule,
- G_TYPE_INVALID,
G_TYPE_INVALID)) {
g_warning ("%s: %s", error->name, error->message);
ibus_error_free (error);
"AddMatch",
&error,
G_TYPE_STRING, &rule,
- G_TYPE_INVALID,
G_TYPE_INVALID)) {
g_warning ("%s: %s", error->name, error->message);
ibus_error_free (error);
"RemoveMatch",
&error,
G_TYPE_STRING, &rule,
- G_TYPE_INVALID,
G_TYPE_INVALID)) {
g_warning ("%s: %s", error->name, error->message);
"RemoveMatch",
&error,
G_TYPE_STRING, &rule,
- G_TYPE_INVALID,
G_TYPE_INVALID)) {
g_warning ("%s: %s", error->name, error->message);
priv = IBUS_PROXY_GET_PRIVATE (proxy);
if (priv->unique_name == NULL && priv->connection != NULL) {
- IBusError *error;
- gchar *owner;
- if (!ibus_connection_call (priv->connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- "GetNameOwner",
- &error,
- G_TYPE_STRING, &(priv->name),
- G_TYPE_INVALID,
- G_TYPE_STRING, &owner,
- G_TYPE_INVALID)) {
- g_warning ("%s: %s", error->name, error->message);
- ibus_error_free (error);
+ IBusMessage *reply = NULL;
+ IBusError *error = NULL;
+ gchar *owner = NULL;
+ reply = ibus_connection_call_with_reply (priv->connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ "GetNameOwner",
+ NULL,
+ G_TYPE_STRING, &(priv->name),
+ G_TYPE_INVALID);
+ if (reply) {
+ if (ibus_message_get_args (reply, &error, G_TYPE_STRING, &owner,
+ G_TYPE_INVALID)) {
+ priv->unique_name = g_strdup (owner);
+ } else {
+ g_warning ("%s: %s", error->name, error->message);
+ ibus_error_free (error);
+ }
+
+ ibus_message_unref (reply);
}
- priv->unique_name = g_strdup (owner);
}
return priv->unique_name;