| Libtlen2 Reference Manual |
|---|
struct TlenConnection; TlenConnection* tlen_connection_new (const gchar *username, const gchar *password); gboolean tlen_connection_open (TlenConnection *tc, TlenEventCallback event_cb); gboolean tlen_connection_close (TlenConnection *tc); gboolean tlen_connection_delete (TlenConnection *tc); gboolean tlen_connection_socket_writen (TlenConnection *tc, gpointer buffer, gsize length, gsize *bytes_n); gboolean tlen_connection_socket_readn (TlenConnection *tc, gpointer buffer, gsize length, gsize *bytes_n); gboolean tlen_connection_socket_readline (TlenConnection *tc, gchar **buffer);
struct TlenConnection {
gchar *username;
gchar *password;
gchar *hostname;
gchar *sid;
guint port;
GTcpSocket *socket;
guchar state;
TlenPresenceType status;
gchar *description;
GSList *events_list;
TlenEventCallback event_cb;
GString *buffer;
/*TlenErrorType error;*/
gboolean critical_failure;
gboolean id_parsed;
};TlenConnection* tlen_connection_new (const gchar *username, const gchar *password);
Creates new TlenConnection object with given username and password.
| username : | user used while logging into the server. |
| password : | used password. |
| Returns : | new TlenConnection on success, NULL otherwise. |
gboolean tlen_connection_open (TlenConnection *tc, TlenEventCallback event_cb);
Opens new connection with the server in non-blocking mode.
| tc : | pointer to TlenConnection. |
| event_cb : | |
| Returns : | TRUE on success, FALSE otherwise. |
gboolean tlen_connection_close (TlenConnection *tc);
Closes given connection with the server by sending presence of type unavailable.
Note: You should wait for TLEN_EVENT_DISCONNECTED before you run tlen_connection_delete.
| tc : | TlenConnection to close. |
| Returns : | TRUE on success, FALSE otherwise. |
gboolean tlen_connection_delete (TlenConnection *tc);
Frees object pointed by tc. If there are opened connections associated with this object then they are closed.
Note: You should run tlen_connection_close first if your were logged.
| tc : | TlenConnection to delete. |
| Returns : | TRUE on success, FALSE otherwise. |
gboolean tlen_connection_socket_writen (TlenConnection *tc, gpointer buffer, gsize length, gsize *bytes_n);
Writes all length bytes in buffer to tc. If bytes_n is set, the number of bytes written is stored in the integer it points to. bytes_n will be less than length if the connection closed or an error occured.
| tc : | TlenConnection object to use. |
| buffer : | buffer to read from. |
| length : | length of buffer. |
| bytes_n : | pointer to integer in which to store the number of bytes written. |
| Returns : | TRUE on success, FALSE otherwise. |
gboolean tlen_connection_socket_readn (TlenConnection *tc, gpointer buffer, gsize length, gsize *bytes_n);
Read length bytes from tc into buffer. If bytes_n is set, the number of bytes read is stored in the integer it points to. bytes_n will be less than length if the end-of-file was reached or an error occured.
| tc : | TlenConnection object to use. |
| buffer : | buffer to write to. |
| length : | |
| bytes_n : | |
| Returns : | TRUE on success, FALSE otherwise. |
gboolean tlen_connection_socket_readline (TlenConnection *tc, gchar **buffer);
Read a line from tc. buffer must be freed after use.
| tc : | TlenConnection object to use. |
| buffer : | pointer to gchar* in which to store the new buffer. |
| Returns : | TRUE on success, FALSE otherwise. |
| <<< Debug | Events >>> |