IBusServer

## IBusServer IBusServer — Server that listen on a socket and wait for connection requests. |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

                        IBusServer;
                        IBusServerClass;
    void                (*IBusNewConnectionFunc)            (IBusServer *server,
                                                             IBusConnection *connection);
    IBusServer *        ibus_server_new                     (void);
    gboolean            ibus_server_listen                  (IBusServer *server,
                                                             const gchar *address);
    void                ibus_server_disconnect              (IBusServer *server);
    const gchar *       ibus_server_get_address             (IBusServer *server);
    const gchar *       ibus_server_get_id                  (IBusServer *server);
    gboolean            ibus_server_is_connected            (IBusServer *server);
    gboolean            ibus_server_set_auth_mechanisms     (IBusServer *server,
                                                             const gchar **mechanisms);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----IBusObject
                   +----IBusServer

## Properties

      "connection-type"          GType*                : Read / Write

## Signals

      "new-connection"                                 : Run Last

## Description

An IBusServer listen on a socket and wait for connections requests, just like DBusServer.

## Details

### IBusServer

    typedef struct _IBusServer IBusServer;

An opaque object representing an IBusServer.

### IBusServerClass

    typedef struct {
        IBusObjectClass parent;

        /* signals */
        void  (* new_connection)    (IBusServer     *server,
                                     IBusConnection *connectin);
    } IBusServerClass;

### IBusNewConnectionFunc ()

    void                (*IBusNewConnectionFunc)            (IBusServer *server,
                                                             IBusConnection *connection);

Prototype of new connection callback function.

This callback should be connected to signal ::new-connection to handle the event that a new connection is coming in. In this handler, IBus could add a reference and continue processing the connection. If no reference is added, the new connection will be released and closed after this signal.

`see_also`: ::new-connection

`server` : | An IBusServer.
`connection` : | The corresponding IBusConnection.

### ibus_server_new ()

    IBusServer *        ibus_server_new                     (void);

New an IBusServer.

Returns : | A newly allocated IBusServer instance.

### ibus_server_listen ()

    gboolean            ibus_server_listen                  (IBusServer *server,
                                                             const gchar *address);

Listens for new connections on the given address.

If there are multiple semicolon-separated address entries in the address, tries each one and listens on the first one that works.

Returns FALSE if listening fails for any reason.

To free the server, applications must call first `ibus_server_disconnect()` and then `dbus_server_unref()`.

`server` : | An IBusServer.
`address` : | Address of this server.
Returns : | TRUE if succeed ; FALSE otherwise.

### ibus_server_disconnect ()

    void                ibus_server_disconnect              (IBusServer *server);

Releases the server's address and stops listening for new clients.

If called more than once, only the first call has an effect. Does not modify the server's reference count.

`server` : | An IBusServer.

### ibus_server_get_address ()

    const gchar *       ibus_server_get_address             (IBusServer *server);

Returns the address of the server, as a newly-allocated string which must be freed by the caller.

`server` : | An IBusServer.
Returns : | A newly allocated string which contain address.

### ibus_server_get_id ()

    const gchar *       ibus_server_get_id                  (IBusServer *server);

Returns the unique ID of the server, as a newly-allocated string which must be freed by the caller.

This ID is normally used by clients to tell when two IBusConnection would be equivalent (because the server address passed to `ibus_connection_open()` will have the same guid in the two cases). `ibus_connection_open()` can re-use an existing connection with the same ID instead of opening a new connection.

This is an ID unique to each IBusServer. Remember that an IBusServer represents only one mode of connecting, so e.g. a bus daemon can listen on multiple addresses which will mean it has multiple IBusServer each with their own ID.

The ID is not a UUID in the sense of RFC4122; the details are explained in the D-Bus specification. Returns the address of the server, as a newly-allocated string which must be freed by the caller.

`server` : | An IBusServer.
Returns : | A newly allocated string which contain address.

### ibus_server_is_connected ()

    gboolean            ibus_server_is_connected            (IBusServer *server);

Returns TRUE if the server is still listening for new connections.

`server` : | An IBusServer.
Returns : | TRUE if the server is still listening for new connections; FALSE otherwise.

### ibus_server_set_auth_mechanisms ()

    gboolean            ibus_server_set_auth_mechanisms     (IBusServer *server,
                                                             const gchar **mechanisms);

Sets the authentication mechanisms that this server offers to clients, as a NULL-terminated array of mechanism names.

This function only affects connections created after it is called. Pass NULL instead of an array to use all available mechanisms (this is the default behavior).

The D-Bus specification describes some of the supported mechanisms.

`server` : | An IBusServer.
`mechanisms` : | NULL-terminated array of mechanisms.
Returns : | TRUE if succeed; FALSE if insufficient memory.

## Property Details

### The `"connection-type"` property

      "connection-type"          GType*                : Read / Write

The connection type of server object.

## Signal Details

### The `"new-connection"` signal

    void                user_function                      (IBusServer *server,
                                                            GObject    *connection,
                                                            gpointer    user_data)       : Run Last

Emitted when a new connection is coming in. In this handler, IBus could add a reference and continue processing the connection. If no reference is added, the new connection will be released and closed after this signal.

### Note

Argument `user_data` is ignored in this function.

See also: `IBusNewConnectionFunc()`.

`server` : | An IBusServer.
`connection` : | The corresponding IBusConnection.
`user_data` : | user data set when the signal handler was connected.