Top | ![]() |
![]() |
![]() |
![]() |
#define | LM_CONNECTION_DEFAULT_PORT |
#define | LM_CONNECTION_DEFAULT_PORT_SSL |
LmConnection | |
enum | LmHandlerResult |
enum | LmHandlerPriority |
enum | LmDisconnectReason |
enum | LmConnectionState |
void (*LmResultFunction) (LmConnection *connection
,gboolean success
,gpointer user_data
);
void (*LmDisconnectFunction) (LmConnection *connection
,LmDisconnectReason reason
,gpointer user_data
);
LmConnection *
lm_connection_new (const gchar *server
);
Creates a new closed connection. To open the connection call
lm_connection_open()
. server
can be NULL but must be set before calling lm_connection_open()
.
LmConnection * lm_connection_new_with_context (const gchar *server
,GMainContext *context
);
Creates a new closed connection running in a certain context. To open the
connection call lm_connection_open. server
can be NULL but must be set
before calling lm_connection_open.
gboolean lm_connection_open (LmConnection *connection
,LmResultFunction function
,gpointer user_data
,GDestroyNotify notify
,GError **error
);
An async call to open connection
. When the connection is open function
will be called.
connection |
LmConnection to open |
|
function |
Callback function that will be called when the connection is open. |
|
user_data |
User data that will be passed to |
|
notify |
Function for freeing that user_data, can be NULL. |
|
error |
location to store error, or |
gboolean lm_connection_open_and_block (LmConnection *connection
,GError **error
);
Opens connection
and waits until the stream is setup.
gboolean lm_connection_close (LmConnection *connection
,GError **error
);
A synchronous call to close the connection. When returning the connection is considered to be closed and can be opened again with lm_connection_open()
.
gboolean lm_connection_authenticate (LmConnection *connection
,const gchar *username
,const gchar *password
,const gchar *resource
,LmResultFunction function
,gpointer user_data
,GDestroyNotify notify
,GError **error
);
Tries to authenticate a user against the server. The LmResult in the result callback function
will say whether it succeeded or not.
connection |
LmConnection to authenticate. |
|
username |
Username used to authenticate. |
|
password |
Password corresponding to |
|
resource |
Resource used for this connection. |
|
function |
Callback called when authentication is finished. |
|
user_data |
Userdata passed to |
|
notify |
Destroy function to free the memory used by |
|
error |
location to store error, or |
gboolean lm_connection_authenticate_and_block (LmConnection *connection
,const gchar *username
,const gchar *password
,const gchar *resource
,GError **error
);
Tries to authenticate a user against the server. This function blocks until a reply to the authentication attempt is returned and returns whether it was successful or not.
connection |
an LmConnection |
|
username |
Username used to authenticate. |
|
password |
Password corresponding to |
|
resource |
Resource used for this connection. |
|
error |
location to store error, or |
guint
lm_connection_get_keep_alive_rate (LmConnection *connection
);
Get the keep alive rate, in seconds. Zero is returned if no keep alive rate has been set.
Since 1.4.0
void lm_connection_set_keep_alive_rate (LmConnection *connection
,guint rate
);
Set the keep alive rate, in seconds. Set to 0 to prevent keep alive messages to be sent. A keep alive message is a single space character.
gboolean
lm_connection_is_open (LmConnection *connection
);
Check if the connection
is currently open.
gboolean
lm_connection_is_authenticated (LmConnection *connection
);
Check if connection
is authenticated.
const gchar *
lm_connection_get_server (LmConnection *connection
);
Fetches the server address that connection
is using.
void lm_connection_set_server (LmConnection *connection
,const gchar *server
);
Sets the server address for connection
to server
. Notice that connection
can't be open while doing this.
const gchar *
lm_connection_get_jid (LmConnection *connection
);
Fetches the jid set for connection
is using.
void lm_connection_set_jid (LmConnection *connection
,const gchar *jid
);
Sets the JID to be used for connection
.
guint
lm_connection_get_port (LmConnection *connection
);
Fetches the port that connection
is using.
void lm_connection_set_port (LmConnection *connection
,guint port
);
Sets the server port that connection
will be using.
LmSSL *
lm_connection_get_ssl (LmConnection *connection
);
Returns the SSL struct if the connection is using one.
void lm_connection_set_ssl (LmConnection *connection
,LmSSL *ssl
);
Sets SSL struct or unset if ssl
is NULL
. If set connection
will use SSL to for the connection.
LmProxy *
lm_connection_get_proxy (LmConnection *connection
);
Returns the proxy if the connection is using one.
void lm_connection_set_proxy (LmConnection *connection
,LmProxy *proxy
);
Sets the proxy to use for this connection. To unset pass NULL.
gboolean lm_connection_send (LmConnection *connection
,LmMessage *message
,GError **error
);
Asynchronous call to send a message.
connection |
LmConnection to send message over. |
|
message |
LmMessage to send. |
|
error |
location to store error, or |
gboolean lm_connection_send_with_reply (LmConnection *connection
,LmMessage *message
,LmMessageHandler *handler
,GError **error
);
Send a LmMessage which will result in a reply.
connection |
LmConnection used to send message. |
|
message |
LmMessage to send. |
|
handler |
LmMessageHandler that will be used when a reply to |
|
error |
location to store error, or |
LmMessage * lm_connection_send_with_reply_and_block (LmConnection *connection
,LmMessage *message
,GError **error
);
Send message
and wait for return.
connection |
an LmConnection |
|
message |
an LmMessage |
|
error |
Set if error was detected during sending. |
void lm_connection_register_message_handler (LmConnection *connection
,LmMessageHandler *handler
,LmMessageType type
,LmHandlerPriority priority
);
Registers a LmMessageHandler to handle incoming messages of a certain type.
To unregister the handler call lm_connection_unregister_message_handler()
.
void lm_connection_unregister_message_handler (LmConnection *connection
,LmMessageHandler *handler
,LmMessageType type
);
Unregisters a handler for connection
. handler
will no longer be called
when incoming messages of type
arrive.
void lm_connection_set_disconnect_function (LmConnection *connection
,LmDisconnectFunction function
,gpointer user_data
,GDestroyNotify notify
);
Set the callback that will be called when a connection is closed.
gboolean lm_connection_send_raw (LmConnection *connection
,const gchar *str
,GError **error
);
Asynchronous call to send a raw string. Useful for debugging and testing.
LmConnectionState
lm_connection_get_state (LmConnection *connection
);
Returns the state of the connection.
LmConnection *
lm_connection_ref (LmConnection *connection
);
Add a reference on connection
. To remove a reference call
lm_connection_unref()
.
void
lm_connection_unref (LmConnection *connection
);
Removes a reference on connection
. If there are no references to
connection
it will be freed and shouldn't be used again.