API DOC for IBusConnection.
authordchen@redhat.com <dchen@redhat.com>
Wed, 15 Apr 2009 08:38:51 +0000 (18:38 +1000)
committerdchen@redhat.com <dchen@dchen.redhat.com>
Thu, 16 Apr 2009 23:42:16 +0000 (09:42 +1000)
docs/reference/ibus/Makefile.am
src/ibusconnection.c
src/ibusconnection.h

index c71de75edfd267d5fd1d407e27c80c604c50f2c6..3682251c3d705c6badf52d5253a690ce14f6b1c9 100644 (file)
@@ -26,7 +26,6 @@ SCANGOBJ_OPTIONS=
 # Extra options to supply to gtkdoc-scan.
 # e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
 SCAN_OPTIONS=--rebuild-sections
-#SCAN_OPTIONS=
 
 # Extra options to supply to gtkdoc-mkdb.
 # e.g. MKDB_OPTIONS=--sgml-mode --output-format=xml
@@ -44,7 +43,7 @@ FIXXREF_OPTIONS=
 # e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
 # e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
 HFILE_GLOB=$(top_srcdir)/src/*.h
-CFILE_GLOB=
+CFILE_GLOB=$(top_srcdir)/src/*.c
 
 # Header files to ignore when scanning.
 # e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
index 130426c48c7051c51cfcbe3e4346dee58b379c70..4a135ddd40555463db204717c94b2b2ebc1dbe75 100644 (file)
@@ -113,9 +113,12 @@ ibus_connection_class_init (IBusConnectionClass *klass)
 
     /* install signals */
     /**
-     * IBusConnnection:ibus-message:
+     * IBusConnnection::ibus-message:
+     * @ibusconnection: The object which received the signal.
+     * @message: An IBusMessage.
+     * @returns: TRUE if succeed; FALSE otherwise.
      *
-     * Emitted when sending an ibus-message.
+     * Emitted ::ibus-message when sending an ibus-message.
      * Implement this function in extended class to receive this signal.
      */
     connection_signals[IBUS_MESSAGE] =
@@ -129,9 +132,12 @@ ibus_connection_class_init (IBusConnectionClass *klass)
             G_TYPE_POINTER);
 
     /**
-     * IBusConnnection:ibus-singal:
+     * IBusConnnection::ibus-signal:
+     * @ibusconnection: The object which received the signal.
+     * @message: An IBusMessage that contain the signal.
+     * @returns: TRUE if succeed; FALSE otherwise.
      *
-     * Emitted when sending an ibus-singal.
+     * Emitted ::ibus-signal when sending an ibus-signal.
      * Implement this function in extended class to receive this signal.
      */
     connection_signals[IBUS_SIGNAL] =
@@ -145,9 +151,11 @@ ibus_connection_class_init (IBusConnectionClass *klass)
             G_TYPE_POINTER);
 
     /**
-     * IBusConnnection:ibus-message-sent:
+     * IBusConnnection::ibus-message-sent:
+     * @ibusconnection: The object which received the signal.
+     * @message: An IBusMessage that contain the signal.
      *
-     * Emitted when an ibus-message is sent.
+     * Emitted ::ibus-message-sent when an ibus-message is sent.
      * Implement this function in extended class to receive this signal.
      */
     connection_signals[IBUS_MESSAGE_SENT] =
@@ -161,9 +169,10 @@ ibus_connection_class_init (IBusConnectionClass *klass)
             G_TYPE_POINTER);
 
     /**
-     * IBusConnnection:ibus-message-disconnected:
+     * IBusConnnection::disconnect:
+     * @ibusconnection: The object which received the signal.
      *
-     * Emitted when an ibus-message is disconnected.
+     * Emitted ::disconnect when an ibus-message is disconnected.
      * Implement this function in extended class to receive this signal.
      */
     connection_signals[DISCONNECTED] =
@@ -717,8 +726,8 @@ ibus_connection_call (IBusConnection     *connection,
     else {
         retval = TRUE;
     }
-    
-    va_end (args);    
+
+    va_end (args);
     ibus_message_unref (reply);
 
     return retval;
index 20427913e3d0e04d196b467c8e4cba071c6b6142..b4a5539d230cf5da50716fde00cdc51d50c4b2a7 100644 (file)
 /**
  * SECTION: ibusconnection
  * @short_description: DBusConnection wrapper.
- * @see_also: <ulink url="http://dbus.freedesktop.org/doc/api/html/structDBusConnection.html">DBusConnection</ulink>
+ * @see_also: IBusMessage
+ * <ulink url="http://dbus.freedesktop.org/doc/api/html/structDBusConnection.html">DBusConnection</ulink>
  *
- * An IBusConnection provides DBusConnection wrapper.
- * It can be used to connect to either dBus or IBus daemon.
+ * An IBusConnection provides DBusConnection wrapper, and is used to connect to either D-Bus or IBus daemon.
+ * Usually, IBusConnection is set to a DBusConnection and emitting ibus-message when
+ * receiving incoming messages from the DBusConnection.
  */
 
 #ifndef __IBUS_CONNECTION_H_
@@ -58,18 +60,60 @@ G_BEGIN_DECLS
 typedef struct _IBusConnection IBusConnection;
 typedef struct _IBusConnectionClass IBusConnectionClass;
 
+/**
+ * IBusIBusMessageFunc:
+ * @connection: An IBusConnection.
+ * @message: An IBusMessage.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Prototype of an IBusIBusMessage callback function.
+ */
 typedef gboolean (* IBusIBusMessageFunc)(IBusConnection     *connection,
                                          IBusMessage        *message);
+
+/**
+ * IBusIBusSignalFunc:
+ * @connection: An IBusConnection.
+ * @message: An IBusMessage.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Prototype of an IBusIBusSignal callback function.
+ */
 typedef gboolean (* IBusIBusSignalFunc) (IBusConnection     *connection,
                                          IBusMessage        *message);
+
+/**
+ * IBusMessageFunc:
+ * @connection: An IBusConnection.
+ * @message: An IBusMessage.
+ * @user_data: User data for the callback function.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Prototype of an IBusMessage callback function.
+ */
 typedef gboolean (* IBusMessageFunc)    (IBusConnection     *connection,
                                          IBusMessage        *message,
                                          gpointer            user_data);
+
+/**
+ * IBusConnectionReplyFunc:
+ * @connection: An IBusConnection.
+ * @reply: An IBusMessage.
+ * @user_data: User data for the callback function.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Prototype of an IBusConnectionReplyFunc callback function.
+ */
 typedef void     (* IBusConnectionReplyFunc)
                                         (IBusConnection     *connection,
                                          IBusMessage        *reply,
                                          gpointer            user_data);
 
+/**
+ * IBusConnection:
+ *
+ * An opaque data type representing an IBusConnection.
+ */
 struct _IBusConnection {
   IBusObject parent;
   /* instance members */
@@ -102,30 +146,201 @@ GType            ibus_connection_get_type           (void);
  * New an IBusConnection.
  */
 IBusConnection  *ibus_connection_new                (void);
+
+/**
+ * ibus_connection_set_connection:
+ * @connection: An IBusConnection.
+ * @dbus_connection: A D-Bus connection.
+ * @shared: Whether the @dbus_connection is shared.
+ *
+ * Set an IBusConnection as data of a D-Bus connection.
+ * Emit signal <constant>ibus-message</constant> when receiving incoming message from @dbus_connection.
+ */
 void             ibus_connection_set_connection     (IBusConnection     *connection,
                                                      DBusConnection     *dbus_connection,
                                                      gboolean            shared);
+
+/**
+ * ibus_connection_open:
+ * @address: A remote address.
+ * @returns: A newly allocated IBusConnection which is set to a D-Bus connection corresponding to @address.
+ *
+ * Open an IBusConnection that is set to a D-Bus connection to the specified address.
+ * Use ibus_connection_open_private() to get a dedicated connection not shared with other callers of
+ * ibus_connection_open().
+ *
+ * @see_also: ibus_connection_open_private().
+ */
 IBusConnection  *ibus_connection_open               (const gchar        *address);
+
+/**
+ * ibus_connection_open_private:
+ * @address: A remote address.
+ * @returns: A newly allocated IBusConnection which is set to a D-Bus connection corresponding to @address.
+ *
+ * Open an IBusConnection that is set to a D-Bus connection to the specified address.
+ * Unlike ibus_connection_open(), this function always creates a new D-Bus connection.
+ * The D-Bus connection will not be saved or recycled by libdbus.
+ *
+ * In D-Bus documentation, dbus_connection_open() is preferred over dbus_connection_open_private(),
+ * so should ibus_connection_open() be preferred over ibus_connection_open_private().
+ *
+ * @see_also: ibus_connection_open().
+ */
 IBusConnection  *ibus_connection_open_private       (const gchar        *address);
+
+/**
+ * ibus_connection_close:
+ * @connection: An IBusConnection.
+ *
+ * Close an IBusCOnnection and corresponding D-Bus connection.
+ */
 void             ibus_connection_close              (IBusConnection     *connection);
+
+/**
+ * ibus_connection_is_connected:
+ * @connection: An IBusConnection.
+ * @returns: TRUE for connected; FALSE otherwise.
+ *
+ * Whether an IBusConnection is connected.
+ */
 gboolean         ibus_connection_is_connected       (IBusConnection     *connection);
+
+/**
+ * ibus_connection_get_connection:
+ * @connection: An IBusConnection.
+ * @returns: The corresponding DBusConnection.
+ *
+ * Return corresponding DBusConnection.
+ */
 DBusConnection  *ibus_connection_get_connection     (IBusConnection     *connection);
+
+/**
+ * ibus_connection_read_write_dispatch:
+ * @connection: An IBusConnection.
+ * @timeout: Maximum time to block or -1 for infinite.
+ * @returns: TRUE if the disconnect message has not been processed; FALSE otherwise.
+ *
+ * Return TRUE if the disconnect message has not been processed.
+ * This function is a wrapper of dbus_connection_read_write_dispatch(),
+ * which is also intended for use with applications that don't want to
+ * write a main loop and deal with DBusWatch and DBusTimeout.
+ * Following text is
+ * from the documentation of dbus_connection_read_write_dispatch():
+ * An example usage would be:
+ * <informalexample>
+ *     <programlisting>
+ *  while (dbus_connection_read_write_dispatch (connection, -1))
+ * ; // empty loop body
+ *     </programlisting>
+ * </informalexample>
+ * In this usage you would normally have set up a filter function to look at each message as it is dispatched.
+ * The loop terminates when the last message from the connection (the disconnected signal) is processed.
+ *
+ * If there are messages to dispatch, this function will dbus_connection_dispatch() once, and return.
+ * If there are no messages to dispatch, this function will block until it can read or write,
+ * then read or write, then return.
+ *
+ * The way to think of this function is that it either makes some sort of progress,
+ * or it blocks. Note that, while it is blocked on I/O, it cannot be interrupted (even by other threads),
+ * which makes this function unsuitable for applications that do more than just react to received messages.
+ *
+ * @see_also: dbus_connection_read_write_dispatch().
+ */
 gboolean         ibus_connection_read_write_dispatch(IBusConnection     *connection,
                                                      gint                timeout);
+
+/**
+ * ibus_connection_send:
+ * @connection: An IBusConnection.
+ * @message: IBusMessage to be sent.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Send an IBusMessage to an IBusConnection.
+ * If succeed, signal <constant>ibus-message-sent</constant> is emitted.
+ *
+ * @see_also: ibus_connection_send_with_reply(), ibus_connection_send_with_reply_and_block(),
+ * ibus_connection_send_signal(), ibus_connection_send_signal_valist(), ibus_connection_send_valist(),
+ * dbus_connection_send().
+ */
 gboolean         ibus_connection_send               (IBusConnection     *connection,
                                                      IBusMessage        *message);
+
+/**
+ * ibus_connection_send_signal:
+ * @connection: An IBusConnection.
+ * @path: The path to the object emitting the signal.
+ * @interface: The interface the signal is emitted from.
+ * @name: Name of the signal.
+ * @first_arg_type: Type of first arg.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Send a wrapped D-Bus signal to an IBusConnection.
+ * This function wraps a signal as an IBusMessage, then sent the IBusMessage
+ * via ibus_connection_send().
+ *
+ * @see_also: ibus_connection_send(), ibus_connection_send_signal_valist(), ibus_message_new_signal().
+ */
 gboolean         ibus_connection_send_signal        (IBusConnection     *connection,
                                                      const gchar        *path,
                                                      const gchar        *interface,
                                                      const gchar        *name,
                                                      GType               first_arg_type,
                                                      ...);
+
+/**
+ * ibus_connection_send_signal_valist:
+ * @connection: An IBusConnection.
+ * @path: The path to the object emitting the signal.
+ * @interface: The interface the signal is emitted from.
+ * @name: Name of the signal.
+ * @first_arg_type: Type of first arg.
+ * @args: Ret of arguments.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Send a wrapped D-Bus signal to an IBusConnection.
+ * This function wraps a signal as an IBusMessage, then sent the IBusMessage
+ * via ibus_connection_send().
+ *
+ * @see_also: ibus_connection_send(), ibus_connection_send_signal(), ibus_connection_send_valist(),
+ *  ibus_message_new_signal().
+ */
 gboolean         ibus_connection_send_signal_valist (IBusConnection     *connection,
                                                      const gchar        *path,
                                                      const gchar        *interface,
                                                      const gchar        *name,
                                                      GType               first_arg_type,
                                                      va_list             args);
+
+/**
+ * ibus_connection_send_valist:
+ * @connection: An IBusConnection.
+ * @message_type: Message type.
+ * @path: The path to the object emitting the signal.
+ * @interface: The interface the signal is emitted from.
+ * @name: Name of the signal.
+ * @first_arg_type: Type of first arg.
+ * @args: Ret of arguments.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Send a wrapped D-Bus message to an IBusConnection.
+ *
+ * This function wraps a D-Bus message as an IBusMessage, then sent the IBusMessage
+ * via ibus_connection_send().
+ *
+ * Message type can be specified with @message_type.
+ * Types include <constant>DBUS_MESSAGE_TYPE_METHOD_CALL</constant>,
+ * <constant>DBUS_MESSAGE_TYPE_METHOD_RETURN</constant>,
+ * <constant>DBUS_MESSAGE_TYPE_ERROR</constant>,
+ * <constant>DBUS_MESSAGE_TYPE_SIGNAL</constant>,
+ * but other types are allowed and all code must silently ignore messages of unknown type.
+ * <constant>DBUS_MESSAGE_TYPE_INVALID</constant> will never be returned.
+ *
+ * @see_also: ibus_connection_send(), ibus_connection_send_singal_valist(),
+ * ibus_connection_call(),
+ * ibus_message_new_signal(),
+ * dbus_message_get_type().
+ */
 gboolean         ibus_connection_send_valist        (IBusConnection     *connection,
                                                      gint                message_type,
                                                      const gchar        *path,
@@ -133,15 +348,64 @@ gboolean         ibus_connection_send_valist        (IBusConnection     *connect
                                                      const gchar        *name,
                                                      GType               first_arg_type,
                                                      va_list             args);
+
+/**
+ * ibus_connection_send_with_reply:
+ * @connection: An IBusConnection.
+ * @message: An IBusMessage.
+ * @pending_return: Return location for a DBusPendingCall object, or NULL if connection is disconnected.
+ * @timeout_milliseconds: timeout in milliseconds or -1 for default.
+ * @returns: FALSE if no memory, TRUE otherwise.
+ *
+ * Queues an IBusMessage to send,  but also returns a DBusPendingCall used to receive a reply to the message.
+ * This function is a wrapper of dbus_connection_send_with_reply().
+ *
+ * @see_also: ibus_connection_send(), ibus_connection_send_with_reply_and_block(),
+ * #DBusPendingCall, dbus_connection_send_with_reply()
+ */
 gboolean         ibus_connection_send_with_reply    (IBusConnection     *connection,
                                                      IBusMessage        *message,
                                                      IBusPendingCall   **pending_return,
                                                      gint                timeout_milliseconds);
+
+/**
+ * ibus_connection_send_with_reply_and_block:
+ * @connection: An IBusConnection.
+ * @message: An IBusMessage.
+ * @timeout_milliseconds: timeout in milliseconds or -1 for default.
+ * @error: Error is stored here; NULL to ignore error.
+ * @returns: The message that is the reply or NULL with an error code if the function fails.
+ *
+ * Sends an IBus message and blocks a certain time period while waiting for a reply.
+ * If reply is not NULL,  signal <constant>ibus-message-sent</constant> is emitted.
+ *
+ * @see_also: ibus_connection_send(), ibus_connection_send_with_reply(),
+ * #DBusPendingCall, dbus_connection_send_with_reply_and_block()
+ */
 IBusMessage     *ibus_connection_send_with_reply_and_block
                                                     (IBusConnection     *connection,
                                                      IBusMessage        *message,
                                                      gint                timeout_milliseconds,
                                                      IBusError          **error);
+
+/**
+ * ibus_connection_call:
+ * @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: Error is stored here; NULL to ignore error.
+ * @message: An IBusMessage.
+ * @timeout_milliseconds: timeout in milliseconds or -1 for default.
+ * @error: Error is stored here; NULL to ignore error.
+ * @first_arg_type: Type of first arg.
+ * @returns: TRUE if succeed; FALSE otherwise.
+ *
+ * Invoke a member function by sending an IBusMessage.
+ *
+ * @see_also: ibus_connection_send_valist().
+ */
 gboolean         ibus_connection_call               (IBusConnection     *connection,
                                                      const gchar        *name,
                                                      const gchar        *path,
@@ -150,12 +414,49 @@ gboolean         ibus_connection_call               (IBusConnection     *connect
                                                      IBusError          **error,
                                                      GType              first_arg_type,
                                                      ...);
+
+/**
+ * ibus_connection_call:
+ * @connection: An IBusConnection.
+ *
+ * Blocks until the outgoing message queue is empty.
+ * This function is a wrapper of dbus_connection_flush().
+ *
+ * @see_also: dbus_connection_flush()
+ */
 void             ibus_connection_flush              (IBusConnection     *connection);
+
+/**
+ * ibus_connection_register_object_path:
+ * @connection: An IBusConnection.
+ * @path: Object path to be register.
+ * @message_func: Callback function for message handling.
+ * @user_data: User data for @message_func.
+ * @returns: FALSE if fail because of out of memory; TRUE otherwise.
+ *
+ * Registers a handler for a given path in the object hierarchy.
+ * The given vtable handles messages sent to exactly the given path.
+ * This function is a wrapper of dbus_connection_register_object_path().
+ *
+ * @see_also: ibus_connection_register_object_path()
+ */
 gboolean         ibus_connection_register_object_path
                                                     (IBusConnection     *connection,
                                                      const gchar        *path,
                                                      IBusMessageFunc    message_func,
                                                      gpointer           user_data);
+
+/**
+ * ibus_connection_unregister_object_path:
+ * @connection: An IBusConnection.
+ * @path: Object path to be unregister.
+ * @returns: FALSE if fail because of out of memory; TRUE otherwise.
+ *
+ * Unregisters the handler registered with exactly the given path.
+ * It's a bug to call this function for a path that isn't registered.
+ * Can unregister both fallback paths and object paths.
+ * This function is a wrapper of dbus_connection_unregister_object_path()
+ */
 gboolean         ibus_connection_unregister_object_path
                                                     (IBusConnection     *connection,
                                                      const gchar        *path);