wocky Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
WockyPorterWockyPorter — Wrapper around a WockyXmppConnection providing a higher level API. |
WockyPorter; WockyPorterClass; WockyPorterPrivate; enum WockyPorterError; GQuark wocky_porter_error_quark (void
); #define WOCKY_PORTER_HANDLER_PRIORITY_MIN #define WOCKY_PORTER_HANDLER_PRIORITY_NORMAL #define WOCKY_PORTER_HANDLER_PRIORITY_MAX #define WOCKY_PORTER_ERROR WockyPorter * wocky_porter_new (WockyXmppConnection *connection
,const gchar *full_jid
); const gchar * wocky_porter_get_full_jid (WockyPorter *self
); const gchar * wocky_porter_get_bare_jid (WockyPorter *self
); const gchar * wocky_porter_get_resource (WockyPorter *self
); void wocky_porter_send_async (WockyPorter *porter
,WockyStanza *stanza
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gboolean wocky_porter_send_finish (WockyPorter *porter
,GAsyncResult *result
,GError **error
); void wocky_porter_send (WockyPorter *porter
,WockyStanza *stanza
); void wocky_porter_start (WockyPorter *porter
); gboolean (*WockyPorterHandlerFunc) (WockyPorter *porter
,WockyStanza *stanza
,gpointer user_data
); guint wocky_porter_register_handler (WockyPorter *self
,WockyStanzaType type
,WockyStanzaSubType sub_type
,const gchar *from
,guint priority
,WockyPorterHandlerFunc callback
,gpointer user_data
,...
); void wocky_porter_unregister_handler (WockyPorter *porter
,guint id
); void wocky_porter_close_async (WockyPorter *porter
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gboolean wocky_porter_close_finish (WockyPorter *porter
,GAsyncResult *result
,GError **error
); void wocky_porter_send_iq_async (WockyPorter *porter
,WockyStanza *stanza
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); WockyStanza * wocky_porter_send_iq_finish (WockyPorter *porter
,GAsyncResult *result
,GError **error
); void wocky_porter_force_close_async (WockyPorter *porter
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gboolean wocky_porter_force_close_finish (WockyPorter *porter
,GAsyncResult *result
,GError **error
);
"bare-jid" gchar* : Read "connection" WockyXmppConnection* : Read / Write / Construct Only "full-jid" gchar* : Read / Write / Construct Only "resource" gchar* : Read
"closing" : Run Last "remote-closed" : Run Last "remote-error" : Run Last "sending" : Run Last
typedef struct _WockyPorter WockyPorter;
An object providing a convenient wrapper around a WockyXmppConnection to send and receive stanzas.
typedef enum { WOCKY_PORTER_ERROR_NOT_STARTED, WOCKY_PORTER_ERROR_CLOSING, WOCKY_PORTER_ERROR_CLOSED, WOCKY_PORTER_ERROR_NOT_IQ, WOCKY_PORTER_ERROR_FORCIBLY_CLOSED, } WockyPorterError;
The WockyPorter specific errors.
The WockyPorter has not been started yet | |
The WockyPorter is closing | |
The WockyPorter is closed | |
The WockyStanza is not an IQ | |
The WockyPorter has been forced to close |
GQuark wocky_porter_error_quark (void
);
Get the error quark used by the porter.
Returns : |
the quark for porter errors. |
#define WOCKY_PORTER_HANDLER_PRIORITY_NORMAL (guint) (G_MAXUINT / 2)
#define WOCKY_PORTER_ERROR (wocky_porter_error_quark ())
Get access to the error quark of the xmpp porter.
WockyPorter * wocky_porter_new (WockyXmppConnection *connection
,const gchar *full_jid
);
Convenience function to create a new WockyPorter.
|
WockyXmppConnection which will be used to receive and send WockyStanza |
|
the full JID of the user |
Returns : |
a new WockyPorter. |
const gchar * wocky_porter_get_full_jid (WockyPorter *self
);
|
a porter |
Returns : |
the value of "full-jid". [transfer none] |
const gchar * wocky_porter_get_bare_jid (WockyPorter *self
);
|
a porter |
Returns : |
the value of "bare-jid". [transfer none] |
const gchar * wocky_porter_get_resource (WockyPorter *self
);
|
a porter |
Returns : |
the value of "resource". [transfer none] |
void wocky_porter_send_async (WockyPorter *porter
,WockyStanza *stanza
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Request asynchronous sending of a WockyStanza.
When the stanza has been sent callback will be called.
You can then call wocky_porter_send_finish()
to get the result
of the operation.
|
a WockyPorter |
|
the WockyStanza to send |
|
optional GCancellable object, NULL to ignore
|
|
callback to call when the request is satisfied |
|
the data to pass to callback function |
gboolean wocky_porter_send_finish (WockyPorter *porter
,GAsyncResult *result
,GError **error
);
Finishes sending a WockyStanza.
|
a WockyPorter |
|
a GAsyncResult |
|
a GError location to store the error occuring, or NULL to
ignore.
|
Returns : |
TRUE on success or FALSE on error.
|
void wocky_porter_send (WockyPorter *porter
,WockyStanza *stanza
);
Send a WockyStanza.
This is a convenient function to not have to call
wocky_porter_send_async()
with lot of NULL
arguments if you don't care to
know when the stanza has been actually sent.
|
a WockyPorter |
|
the WockyStanza to send |
void wocky_porter_start (WockyPorter *porter
);
Start a WockyPorter to make it read and dispatch incoming stanzas.
|
a WockyPorter |
gboolean (*WockyPorterHandlerFunc) (WockyPorter *porter
,WockyStanza *stanza
,gpointer user_data
);
Handler called when a matching stanza has been received by the WockyPorter.
If a handler returns TRUE
, this means that it has taken responsibility
for handling the stanza and (if applicable) sending a reply.
If a handler returns FALSE
, this indicates that it has declined to process
the stanza. The next handler (if any) is invoked.
A handler must not assume that stanza
will continue to exist after the
handler has returned, unless it has taken a reference to stanza
using
g_object_ref()
.
|
the WockyPorter dispatching the WockyStanza |
|
the WockyStanza being dispatched |
|
the data passed when the handler has been registered |
Returns : |
TRUE if the stanza has been handled, FALSE if not
|
guint wocky_porter_register_handler (WockyPorter *self
,WockyStanzaType type
,WockyStanzaSubType sub_type
,const gchar *from
,guint priority
,WockyPorterHandlerFunc callback
,gpointer user_data
,...
);
Register a new stanza handler.
Stanza handlers are called when the Porter receives a new stanza matching
the rules of the handler. Matching handlers are sorted by priority and are
called until one claims to have handled the stanza (by returning TRUE
).
If from
is a bare JID, then the resource of the JID in the from attribute
will be ignored: In other words, a handler registered against a bare JID
will match _all_ stanzas from a JID with the same node and domain:
"foo@bar.org" will match
"foo@bar.org", "foo@bar.org/moose" and so forth.
To register a handler matching all message stanzas received from anyone:
1 2 3 4 |
id = wocky_porter_register_handler (porter, WOCKY_STANZA_TYPE_MESSAGE, WOCKY_STANZA_SUB_TYPE_NONE, NULL, WOCKY_PORTER_HANDLER_PRIORITY_NORMAL, message_received_cb, NULL, NULL); |
To register an IQ handler from Juliet for all the Jingle stanzas related to one Jingle session:
1 2 3 4 5 6 7 8 |
id = wocky_porter_register_handler (porter, WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_NONE, NULL, WOCKY_PORTER_HANDLER_PRIORITY_NORMAL, jingle_cb, "juliet@example.com/Balcony", '(', "jingle", ':', "urn:xmpp:jingle:1", '@', "sid", "my_sid", ')', NULL); |
|
A WockyPorter instance (passed to callback ).
|
|
The type of stanza to be handled, or WOCKY_STANZA_TYPE_NONE to match any type of stanza. |
|
The subtype of stanza to be handled, or WOCKY_STANZA_SUB_TYPE_NONE to match any type of stanza. |
|
the JID whose messages this handler is intended for, or NULL to
match messages from any sender.
|
|
a priority between WOCKY_PORTER_HANDLER_PRIORITY_MIN and
WOCKY_PORTER_HANDLER_PRIORITY_MAX (often
WOCKY_PORTER_HANDLER_PRIORITY_NORMAL ). Handlers with a higher priority
(larger number) are called first.
|
|
A WockyPorterHandlerFunc, which should return FALSE to decline
the stanza (Wocky will continue to the next handler, if any), or TRUE to
stop further processing.
|
|
Passed to callback .
|
|
a wocky_stanza_build() specification. The handler
will match a stanza only if the stanza received is a superset of the one
passed to this function, as per wocky_node_is_superset() .
|
Returns : |
a non-zero ID for use with wocky_porter_unregister_handler() .
|
void wocky_porter_unregister_handler (WockyPorter *porter
,guint id
);
Unregister a registered handler. This handler won't be called when receiving stanzas anymore.
|
a WockyPorter |
|
the id of the handler to unregister |
void wocky_porter_close_async (WockyPorter *porter
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Request asynchronous closing of a WockyPorter. This fires the
WockyPorter::closing signal, flushes the sending queue, closes the XMPP
stream and waits that the other side closes the XMPP stream as well.
When this is done, callback
is called.
You can then call wocky_porter_close_finish()
to get the result of
the operation.
|
a WockyPorter |
|
optional GCancellable object, NULL to ignore
|
|
callback to call when the request is satisfied |
|
the data to pass to callback function |
gboolean wocky_porter_close_finish (WockyPorter *porter
,GAsyncResult *result
,GError **error
);
Finishes a close operation.
|
a WockyPorter |
|
a GAsyncResult |
|
a GError location to store the error occuring, or NULL to ignore.
|
Returns : |
TRUE on success or FALSE on error.
|
void wocky_porter_send_iq_async (WockyPorter *porter
,WockyStanza *stanza
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Request asynchronous sending of a WockyStanza of type
WOCKY_STANZA_TYPE_IQ
and sub-type WOCKY_STANZA_SUB_TYPE_GET
or
WOCKY_STANZA_SUB_TYPE_SET
.
When the reply to this IQ has been received callback will be called.
You can then call wocky_porter_send_iq_finish to get the reply stanza.
|
a WockyPorter |
|
the WockyStanza to send |
|
optional GCancellable object, NULL to ignore
|
|
callback to call when the request is satisfied |
|
the data to pass to callback function |
WockyStanza * wocky_porter_send_iq_finish (WockyPorter *porter
,GAsyncResult *result
,GError **error
);
Get the reply of an IQ query.
|
a WockyPorter |
|
a GAsyncResult |
|
a GError location to store the error occuring, or NULL to ignore.
|
Returns : |
a reffed WockyStanza on success, NULL on error
|
void wocky_porter_force_close_async (WockyPorter *porter
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Force the WockyPorter to close the TCP connection of the underlying
WockyXmppConnection.
If a close operation is pending, it will be completed with the
WOCKY_PORTER_ERROR_FORCE_CLOSING
error.
When the connection has been closed, callback
will be called.
You can then call wocky_porter_force_close_finish()
to get the result of
the operation.
|
a WockyPorter |
|
optional GCancellable object, NULL to ignore
|
|
callback to call when the request is satisfied |
|
the data to pass to callback function |
gboolean wocky_porter_force_close_finish (WockyPorter *porter
,GAsyncResult *result
,GError **error
);
Finishes a force close operation.
|
a WockyPorter |
|
a GAsyncResult |
|
a GError location to store the error occuring, or NULL to ignore.
|
Returns : |
TRUE on success or FALSE on error.
|
"bare-jid"
property"bare-jid" gchar* : Read
The user's bare JID (node@domain).
Default value: NULL
"connection"
property"connection" WockyXmppConnection* : Read / Write / Construct Only
The underlying WockyXmppConnection wrapped by the WockyPorter
"full-jid"
property"full-jid" gchar* : Read / Write / Construct Only
The user's full JID (node@domain/resource).
Default value: NULL
"closing"
signalvoid user_function (WockyPorter *porter, gpointer user_data) : Run Last
The ::closing signal is emitted when the WockyPorter starts to close its XMPP connection. Once this signal has been emitted, the WockyPorter can't be used to send stanzas any more.
|
the object on which the signal is emitted |
|
user data set when the signal handler was connected. |
"remote-closed"
signalvoid user_function (WockyPorter *porter, gpointer user_data) : Run Last
The ::remote-closed signal is emitted when the other side closed the XMPP stream.
|
the object on which the signal is emitted |
|
user data set when the signal handler was connected. |
"remote-error"
signalvoid user_function (WockyPorter *porter, guint domain, gint code, gchar *message, gpointer user_data) : Run Last
The ::remote-error signal is emitted when an error has been detected on the XMPP stream.
|
the object on which the signal is emitted |
|
error domain (a GQuark) |
|
error code |
|
human-readable informative error message |
|
user data set when the signal handler was connected. |
"sending"
signalvoid user_function (WockyPorter *porter, gpointer user_data) : Run Last
The ::writing signal is emitted whenever WockyPorter sends data on the XMPP connection.
|
the object on which the signal is emitted |
|
user data set when the signal handler was connected. |