comparison libpurple/protocols/mxit/mxit.h @ 28526:69aa4660401a

Initial addition of the MXit protocol plugin, provided by the MXit folks themselves.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Sun, 08 Nov 2009 23:55:56 +0000
parents
children 0fd6d016c474
comparison
equal deleted inserted replaced
28525:13e668ef158d 28526:69aa4660401a
1 /*
2 * MXit Protocol libPurple Plugin
3 *
4 * -- MXit libPurple plugin API --
5 *
6 * Pieter Loubser <libpurple@mxit.com>
7 *
8 * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd.
9 * <http://www.mxitlifestyle.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
24 */
25
26 #ifndef _MXIT_H_
27 #define _MXIT_H_
28
29
30 /* internationalize feedback strings */
31 #ifndef _
32 #ifdef GETTEXT_PACKAGE
33 #include <glib/gi18n-lib.h>
34 #else
35 #define _( x ) ( x )
36 #endif
37 #endif
38
39
40 #if defined( __APPLE__ )
41 /* apple architecture */
42 #ifndef HOST_NAME_MAX
43 #define HOST_NAME_MAX 512
44 #endif
45 #elif defined( _WIN32 )
46 /* windows architecture */
47 #define HOST_NAME_MAX 512
48 #include "libc_interface.h"
49 #elif defined( __linux__ )
50 /* linux architecture */
51 #include <net/if.h>
52 #include <sys/ioctl.h>
53 #include <sys/socket.h>
54 #include <netinet/in.h>
55 #include <arpa/inet.h>
56 #else
57 /* other architecture */
58 #ifndef HOST_NAME_MAX
59 #define HOST_NAME_MAX 512
60 #endif
61 #endif
62
63
64 #include "protocol.h"
65 #include "profile.h"
66
67
68 /* Plugin details */
69 #define MXIT_PLUGIN_ID "prpl-loubserp-mxit"
70 #define MXIT_PLUGIN_NAME "MXit"
71 #define MXIT_PLUGIN_VERSION "2.2.0"
72 #define MXIT_PLUGIN_EMAIL "Pieter Loubser <libpurple@mxit.com>"
73 #define MXIT_PLUGIN_WWW "http://www.mxit.com"
74 #define MXIT_PLUGIN_SUMMARY "MXit Protocol Plugin"
75 #define MXIT_PLUGIN_DESC "MXit"
76
77 #define MXIT_HTTP_USERAGENT "libpurple-"MXIT_PLUGIN_VERSION
78
79
80 /* default connection settings */
81 #define DEFAULT_SERVER "stream.mxit.co.za"
82 #define DEFAULT_PORT 9119
83 #define DEFAULT_WAPSITE "http://www.mxit.com"
84 #define DEFAULT_HTTP_SERVER "http://int.poll.mxit.com:80/mxit"
85
86
87 /* Purple account configuration variable names */
88 #define MXIT_CONFIG_STATE "state"
89 #define MXIT_CONFIG_WAPSERVER "wap_server"
90 #define MXIT_CONFIG_DISTCODE "distcode"
91 #define MXIT_CONFIG_CLIENTKEY "clientkey"
92 #define MXIT_CONFIG_DIALCODE "dialcode"
93 #define MXIT_CONFIG_SERVER_ADDR "server"
94 #define MXIT_CONFIG_SERVER_PORT "port"
95 #define MXIT_CONFIG_HTTPSERVER "httpserver"
96 #define MXIT_CONFIG_SPLASHID "splashid"
97 #define MXIT_CONFIG_SPLASHCLICK "splashclick"
98 #define MXIT_CONFIG_SPLASHPOPUP "splashpopup"
99 #define MXIT_CONFIG_COUNTRYCODE "cc"
100 #define MXIT_CONFIG_LOCALE "locale"
101 #define MXIT_CONFIG_USE_HTTP "use_http"
102
103
104 /* account states */
105 #define MXIT_STATE_LOGIN 0x00
106 #define MXIT_STATE_REGISTER1 0x01
107 #define MXIT_STATE_REGISTER2 0x02
108
109
110 /* Client session flags */
111 #define MXIT_FLAG_CONNECTED 0x01 /* established connection to the server */
112 #define MXIT_FLAG_LOGGEDIN 0x02 /* user currently logged in */
113 #define MXIT_FLAG_FIRSTROSTER 0x04 /* set to true once the first roster update has been recevied and processed */
114
115
116 /* define this to enable the link clicking support */
117 #define MXIT_LINK_CLICK
118
119
120 #ifdef MXIT_LINK_CLICK
121 #define MXIT_LINK_PREFIX "gopher://"
122 #define MXIT_LINK_KEY "MXIT"
123 #endif
124
125
126 #define ARRAY_SIZE( x ) ( sizeof( x ) / sizeof( x[0] ) )
127
128
129 /*
130 * data structure containing all MXit session information
131 */
132 struct MXitSession {
133 /* socket connection */
134 char server[HOST_NAME_MAX]; /* MXit server name to connect to */
135 int port; /* MXit server port to connect on */
136 int fd; /* connection file descriptor */
137
138 /* http connection */
139 gboolean http; /* connect to MXit via HTTP and not by socket */
140 char http_server[HOST_NAME_MAX]; /* MXit HTTP server */
141 unsigned int http_sesid; /* HTTP session id */
142 unsigned int http_seqno; /* HTTP request sequence number */
143 guint http_timer_id; /* timer resource id (pidgin) */
144 int http_interval; /* poll inverval */
145 time_t http_last_poll; /* the last time a poll has been sent */
146 guint http_handler; /* HTTP connection handler */
147 void* http_out_req; /* HTTP outstanding request */
148
149 /* client */
150 struct login_data* logindata;
151 char* encpwd; /* encrypted password */
152 char distcode[64]; /* distribution code */
153 char clientkey[16]; /* client key */
154 char dialcode[8]; /* dialing code */
155 short flags; /* client session flags (see above) */
156
157 /* personal (profile) */
158 struct MXitProfile* profile; /* user's profile information */
159 int mood; /* user's current mood */
160
161 /* libpurple */
162 PurpleAccount* acc; /* pointer to the libpurple internal account struct */
163 PurpleConnection* con; /* pointer to the libpurple internal connection struct */
164
165 /* transmit */
166 struct tx_queue queue; /* transmit packet queue (FIFO mode) */
167 time_t last_tx; /* timestamp of last packet sent */
168 int outack; /* outstanding ack packet */
169 guint q_timer; /* timer handler for managing queue */
170
171 /* receive */
172 char rx_lbuf[16]; /* receive byte buffer (socket packet length) */
173 char rx_dbuf[CP_MAX_PACKET]; /* receive byte buffer (raw data) */
174 unsigned int rx_i; /* receive buffer current index */
175 int rx_res; /* amount of bytes still outstanding for the current packet */
176 char rx_state; /* current receiver state */
177 time_t last_rx; /* timestamp of last packet received */
178 GList* active_chats; /* list of all our contacts we received messages from (active chats) */
179
180 /* groupchat */
181 GList* rooms; /* active groupchat rooms */
182
183 /* inline images */
184 GHashTable* iimages; /* table which maps inline images (including emoticons) to purple's imgstore id's */
185 };
186
187
188 char* mxit_status_text( PurpleBuddy* buddy );
189 void mxit_enable_signals( struct MXitSession* session );
190
191 #ifdef MXIT_LINK_CLICK
192 void mxit_register_uri_handler();
193 #endif
194
195
196 #endif /* _MXIT_H_ */
197