Mercurial > pidgin.yaz
comparison libpurple/protocols/mxit/mxit.c @ 28903: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
28901:13e668ef158d | 28903: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 #include <glib.h> | |
27 #include <stdio.h> | |
28 #include <string.h> | |
29 | |
30 #include "purple.h" | |
31 #include "notify.h" | |
32 #include "plugin.h" | |
33 #include "version.h" | |
34 | |
35 #include "mxit.h" | |
36 #include "protocol.h" | |
37 #include "login.h" | |
38 #include "roster.h" | |
39 #include "chunk.h" | |
40 #include "filexfer.h" | |
41 #include "actions.h" | |
42 #include "multimx.h" | |
43 | |
44 | |
45 #ifdef MXIT_LINK_CLICK | |
46 | |
47 | |
48 /* pidgin callback function pointers for URI click interception */ | |
49 static void *(*mxit_pidgin_uri_cb)(const char *uri); | |
50 static PurpleNotifyUiOps* mxit_nots_override_original; | |
51 static PurpleNotifyUiOps mxit_nots_override; | |
52 static int not_link_ref_count = 0; | |
53 | |
54 | |
55 /*------------------------------------------------------------------------ | |
56 * Handle an URI clicked on the UI | |
57 * | |
58 * @param link the link name which has been clicked | |
59 */ | |
60 static void* mxit_link_click( const char* link64 ) | |
61 { | |
62 PurpleAccount* account; | |
63 PurpleConnection* con; | |
64 gchar** parts = NULL; | |
65 gchar* link = NULL; | |
66 unsigned int len; | |
67 | |
68 purple_debug_info( MXIT_PLUGIN_ID, "mxit_link_click (%s)\n", link64 ); | |
69 | |
70 if ( g_ascii_strncasecmp( link64, MXIT_LINK_PREFIX, strlen( MXIT_LINK_PREFIX ) ) != 0 ) { | |
71 /* this is not for us */ | |
72 goto skip; | |
73 } | |
74 | |
75 /* decode the base64 payload */ | |
76 link = (gchar*) purple_base64_decode( link64 + strlen( MXIT_LINK_PREFIX ), &len ); | |
77 purple_debug_info( MXIT_PLUGIN_ID, "Clicked Link: '%s'\n", link ); | |
78 | |
79 parts = g_strsplit( link, "|", 5 ); | |
80 | |
81 /* check if this is a valid mxit link */ | |
82 if ( ( !parts ) || ( !parts[0] ) || ( !parts[1] ) || ( !parts[2] ) || ( !parts[3] ) || ( !parts[4] ) ) { | |
83 /* this is not for us */ | |
84 goto skip; | |
85 } | |
86 else if ( g_ascii_strcasecmp( parts[0], MXIT_LINK_KEY ) != 0 ) { | |
87 /* this is not for us */ | |
88 goto skip; | |
89 } | |
90 | |
91 /* find the account */ | |
92 account = purple_accounts_find( parts[1], parts[2] ); | |
93 if ( !account ) | |
94 goto skip; | |
95 con = purple_account_get_connection( account ); | |
96 | |
97 /* send click message back to MXit */ | |
98 mxit_send_message( con->proto_data, parts[3], parts[4], FALSE ); | |
99 | |
100 g_free( link ); | |
101 link = NULL; | |
102 g_strfreev( parts ); | |
103 parts = NULL; | |
104 | |
105 return (void*) link64; | |
106 | |
107 skip: | |
108 /* this is not an internal mxit link */ | |
109 | |
110 if ( link ) | |
111 g_free( link ); | |
112 link = NULL; | |
113 | |
114 if ( parts ) | |
115 g_strfreev( parts ); | |
116 parts = NULL; | |
117 | |
118 if ( mxit_pidgin_uri_cb ) | |
119 return mxit_pidgin_uri_cb( link64 ); | |
120 else | |
121 return (void*) link64; | |
122 } | |
123 | |
124 | |
125 /*------------------------------------------------------------------------ | |
126 * Register MXit to receive URI click notifications from the UI | |
127 */ | |
128 void mxit_register_uri_handler() | |
129 { | |
130 not_link_ref_count++; | |
131 if ( not_link_ref_count == 1 ) { | |
132 /* make copy of notifications */ | |
133 mxit_nots_override_original = purple_notify_get_ui_ops(); | |
134 memcpy( &mxit_nots_override, mxit_nots_override_original, sizeof( PurpleNotifyUiOps ) ); | |
135 | |
136 /* save previously configured callback function pointer */ | |
137 mxit_pidgin_uri_cb = mxit_nots_override.notify_uri; | |
138 | |
139 /* override the URI function call with MXit's own one */ | |
140 mxit_nots_override.notify_uri = mxit_link_click; | |
141 purple_notify_set_ui_ops( &mxit_nots_override ); | |
142 } | |
143 } | |
144 | |
145 | |
146 /*------------------------------------------------------------------------ | |
147 * Unegister MXit from receiving URI click notifications from the UI | |
148 */ | |
149 static void mxit_unregister_uri_handler() | |
150 { | |
151 not_link_ref_count--; | |
152 if ( not_link_ref_count == 0 ) { | |
153 /* restore the notifications to its original state */ | |
154 purple_notify_set_ui_ops( mxit_nots_override_original ); | |
155 } | |
156 } | |
157 | |
158 #endif | |
159 | |
160 | |
161 /*------------------------------------------------------------------------ | |
162 * This gets called when a new chat conversation is opened by the user | |
163 * | |
164 * @param conv The conversation object | |
165 * @param session The MXit session object | |
166 */ | |
167 static void mxit_cb_chat_created( PurpleConversation* conv, struct MXitSession* session ) | |
168 { | |
169 PurpleConnection* gc; | |
170 struct contact* contact; | |
171 PurpleBuddy* buddy; | |
172 const char* who; | |
173 | |
174 gc = purple_conversation_get_gc( conv ); | |
175 if ( session->con != gc ) { | |
176 /* not our conversation */ | |
177 return; | |
178 } | |
179 else if ( purple_conversation_get_type( conv ) != PURPLE_CONV_TYPE_IM ) { | |
180 /* wrong type of conversation */ | |
181 return; | |
182 } | |
183 | |
184 /* get the contact name */ | |
185 who = purple_conversation_get_name( conv ); | |
186 if ( !who ) | |
187 return; | |
188 | |
189 purple_debug_info( MXIT_PLUGIN_ID, "Conversation started with '%s'\n", who ); | |
190 | |
191 /* find the buddy object */ | |
192 buddy = purple_find_buddy( session->acc, who ); | |
193 if ( ( !buddy ) || ( !buddy->proto_data ) ) | |
194 return; | |
195 | |
196 /* we ignore all conversations with which we have chatted with in this session */ | |
197 if ( find_active_chat( session->active_chats, who ) ) | |
198 return; | |
199 | |
200 /* determite if this buddy is a MXit service */ | |
201 contact = buddy->proto_data; | |
202 switch ( contact->type ) { | |
203 case MXIT_TYPE_BOT : | |
204 case MXIT_TYPE_CHATROOM : | |
205 case MXIT_TYPE_GALLERY : | |
206 case MXIT_TYPE_INFO : | |
207 serv_got_im( session->con, who, "<font color=\"#999999\">Loading menu...</font>\n", PURPLE_MESSAGE_NOTIFY, time( NULL ) ); | |
208 mxit_send_message( session, who, " ", FALSE ); | |
209 default : | |
210 break; | |
211 } | |
212 } | |
213 | |
214 | |
215 /*------------------------------------------------------------------------ | |
216 * Enable some signals to handled by our plugin | |
217 * | |
218 * @param session The MXit session object | |
219 */ | |
220 void mxit_enable_signals( struct MXitSession* session ) | |
221 { | |
222 /* enable the signal when a new conversation is opened by the user */ | |
223 purple_signal_connect_priority( purple_conversations_get_handle(), "conversation-created", session, PURPLE_CALLBACK( mxit_cb_chat_created ), | |
224 session, PURPLE_SIGNAL_PRIORITY_HIGHEST ); | |
225 } | |
226 | |
227 | |
228 /*------------------------------------------------------------------------ | |
229 * Disable some signals handled by our plugin | |
230 * | |
231 * @param session The MXit session object | |
232 */ | |
233 static void mxit_disable_signals( struct MXitSession* session ) | |
234 { | |
235 /* disable the signal when a new conversation is opened by the user */ | |
236 purple_signal_disconnect( purple_conversations_get_handle(), "conversation-created", session, PURPLE_CALLBACK( mxit_cb_chat_created ) ); | |
237 } | |
238 | |
239 | |
240 /*------------------------------------------------------------------------ | |
241 * Return the base icon name. | |
242 * | |
243 * @param account The MXit account object | |
244 * @param buddy The buddy | |
245 * @return The icon name (excluding extension) | |
246 */ | |
247 static const char* mxit_list_icon( PurpleAccount* account, PurpleBuddy* buddy ) | |
248 { | |
249 return "mxit"; | |
250 } | |
251 | |
252 | |
253 /*------------------------------------------------------------------------ | |
254 * Return the emblem icon name. | |
255 * | |
256 * @param buddy The buddy | |
257 * @return The icon name (excluding extension) | |
258 */ | |
259 static const char* mxit_list_emblem( PurpleBuddy* buddy ) | |
260 { | |
261 struct contact* contact = buddy->proto_data; | |
262 | |
263 if ( !contact ) | |
264 return NULL; | |
265 | |
266 switch ( contact-> type ) { | |
267 case MXIT_TYPE_JABBER : /* external contacts via MXit */ | |
268 case MXIT_TYPE_MSN : | |
269 case MXIT_TYPE_YAHOO : | |
270 case MXIT_TYPE_ICQ : | |
271 case MXIT_TYPE_AIM : | |
272 case MXIT_TYPE_QQ : | |
273 case MXIT_TYPE_WV : | |
274 return "external"; | |
275 | |
276 case MXIT_TYPE_BOT : /* MXit services */ | |
277 case MXIT_TYPE_GALLERY : | |
278 case MXIT_TYPE_INFO : | |
279 return "bot"; | |
280 | |
281 case MXIT_TYPE_CHATROOM : /* MXit group chat services */ | |
282 case MXIT_TYPE_MULTIMX : | |
283 default: | |
284 return NULL; | |
285 } | |
286 } | |
287 | |
288 | |
289 /*------------------------------------------------------------------------ | |
290 * Return short string representing buddy's status for display on buddy list. | |
291 * Returns status message (if one is set), or otherwise the mood. | |
292 * | |
293 * @param buddy The buddy. | |
294 * @return The status text | |
295 */ | |
296 char* mxit_status_text( PurpleBuddy* buddy ) | |
297 { | |
298 struct contact* contact = buddy->proto_data; | |
299 | |
300 if ( !contact ) | |
301 return NULL; | |
302 | |
303 if ( contact->statusMsg ) { | |
304 /* status message */ | |
305 return g_strdup( contact-> statusMsg ); | |
306 } | |
307 else { | |
308 /* mood */ | |
309 return g_strdup( mxit_convert_mood_to_name( contact->mood ) ); | |
310 } | |
311 } | |
312 | |
313 | |
314 /*------------------------------------------------------------------------ | |
315 * Return UI tooltip information for a buddy when hovering in buddy list. | |
316 * | |
317 * @param buddy The buddy | |
318 * @param info The tooltip info being returned | |
319 * @param full Return full or summarized information | |
320 */ | |
321 static void mxit_tooltip( PurpleBuddy* buddy, PurpleNotifyUserInfo* info, gboolean full ) | |
322 { | |
323 struct contact* contact = buddy->proto_data; | |
324 | |
325 if ( !contact ) | |
326 return; | |
327 | |
328 /* status (reference: "libpurple/notify.h") */ | |
329 if ( contact->presence != MXIT_PRESENCE_OFFLINE ) | |
330 purple_notify_user_info_add_pair( info, _( "Status" ), mxit_convert_presence_to_name( contact->presence ) ); | |
331 | |
332 /* status message */ | |
333 if ( contact->statusMsg ) | |
334 purple_notify_user_info_add_pair( info, _( "Status Message" ), contact->statusMsg ); | |
335 | |
336 /* mood */ | |
337 if ( contact->mood != MXIT_MOOD_NONE ) | |
338 purple_notify_user_info_add_pair( info, _( "Mood" ), mxit_convert_mood_to_name( contact->mood ) ); | |
339 | |
340 /* subscription type */ | |
341 if ( contact->subtype != 0 ) | |
342 purple_notify_user_info_add_pair( info, _( "Subscription" ), mxit_convert_subtype_to_name( contact->subtype ) ); | |
343 | |
344 /* hidden number */ | |
345 if ( contact->flags & MXIT_CFLAG_HIDDEN ) | |
346 purple_notify_user_info_add_pair( info, _( "Hidden Number" ), "Yes" ); | |
347 } | |
348 | |
349 | |
350 /*------------------------------------------------------------------------ | |
351 * Initiate the logout sequence, close the connection and clear the session data. | |
352 * | |
353 * @param gc The connection object | |
354 */ | |
355 static void mxit_close( PurpleConnection* gc ) | |
356 { | |
357 struct MXitSession* session = (struct MXitSession*) gc->proto_data; | |
358 | |
359 /* disable signals */ | |
360 mxit_disable_signals( session ); | |
361 | |
362 /* close the connection */ | |
363 mxit_close_connection( session ); | |
364 | |
365 #ifdef MXIT_LINK_CLICK | |
366 /* unregister for uri click notification */ | |
367 mxit_unregister_uri_handler(); | |
368 #endif | |
369 | |
370 purple_debug_info( MXIT_PLUGIN_ID, "Releasing the session object..\n" ); | |
371 | |
372 /* free the session memory */ | |
373 g_free( session ); | |
374 session = NULL; | |
375 } | |
376 | |
377 | |
378 /*------------------------------------------------------------------------ | |
379 * Send a message to a contact | |
380 * | |
381 * @param gc The connection object | |
382 * @param who The username of the recipient | |
383 * @param message The message text | |
384 * @param flags Message flags (defined in conversation.h) | |
385 * @return Positive value (success, and echo to conversation window) | |
386 Zero (success, no echo) | |
387 Negative value (error) | |
388 */ | |
389 static int mxit_send_im( PurpleConnection* gc, const char* who, const char* message, PurpleMessageFlags flags ) | |
390 { | |
391 purple_debug_info( MXIT_PLUGIN_ID, "Sending message '%s' to buddy '%s'\n", message, who ); | |
392 | |
393 mxit_send_message( gc->proto_data, who, message, TRUE ); | |
394 | |
395 return 1; /* echo to conversation window */ | |
396 } | |
397 | |
398 | |
399 /*------------------------------------------------------------------------ | |
400 * The user changed their current presence state. | |
401 * | |
402 * @param account The MXit account object | |
403 * @param status The new status (libPurple status type) | |
404 */ | |
405 static void mxit_set_status( PurpleAccount* account, PurpleStatus* status ) | |
406 { | |
407 struct MXitSession* session = purple_account_get_connection( account )->proto_data; | |
408 const char* statusid; | |
409 int presence; | |
410 char* statusmsg1; | |
411 char* statusmsg2; | |
412 | |
413 /* get the status id (reference: "libpurple/status.h") */ | |
414 statusid = purple_status_get_id( status ); | |
415 | |
416 /* convert the purple status to a mxit status */ | |
417 presence = mxit_convert_presence( statusid ); | |
418 if ( presence < 0 ) { | |
419 /* error, status not found */ | |
420 purple_debug_info( MXIT_PLUGIN_ID, "Presence status NOT found! (id = %s)\n", statusid ); | |
421 return; | |
422 } | |
423 | |
424 statusmsg1 = purple_markup_strip_html( purple_status_get_attr_string( status, "message" ) ); | |
425 statusmsg2 = g_strndup( statusmsg1, CP_MAX_STATUS_MSG ); | |
426 purple_debug_info( MXIT_PLUGIN_ID, "mxit_set_status: '%s'\n", statusmsg2 ); | |
427 | |
428 /* update presence state */ | |
429 mxit_send_presence( session, presence, statusmsg2 ); | |
430 | |
431 g_free( statusmsg1 ); | |
432 g_free( statusmsg2 ); | |
433 } | |
434 | |
435 | |
436 /*------------------------------------------------------------------------ | |
437 * MXit supports messages to offline contacts. | |
438 * | |
439 * @param buddy The buddy | |
440 */ | |
441 static gboolean mxit_offline_message( const PurpleBuddy *buddy ) | |
442 { | |
443 return TRUE; | |
444 } | |
445 | |
446 | |
447 /*------------------------------------------------------------------------ | |
448 * Free the resources used to store a buddy. | |
449 * | |
450 * @param buddy The buddy | |
451 */ | |
452 static void mxit_free_buddy( PurpleBuddy* buddy ) | |
453 { | |
454 struct contact* contact; | |
455 | |
456 purple_debug_info( MXIT_PLUGIN_ID, "mxit_free_buddy\n" ); | |
457 | |
458 contact = buddy->proto_data; | |
459 if ( contact ) { | |
460 if ( contact->statusMsg ) | |
461 g_free( contact->statusMsg ); | |
462 if ( contact->avatarId ) | |
463 g_free( contact->avatarId ); | |
464 g_free( contact ); | |
465 } | |
466 buddy->proto_data = NULL; | |
467 } | |
468 | |
469 | |
470 /*------------------------------------------------------------------------ | |
471 * Periodic task called every KEEPALIVE_INTERVAL (30 sec) to to maintain | |
472 * idle connections, timeouts and the transmission queue to the MXit server. | |
473 * | |
474 * @param gc The connection object | |
475 */ | |
476 static void mxit_keepalive( PurpleConnection *gc ) | |
477 { | |
478 struct MXitSession* session = (struct MXitSession*) gc->proto_data; | |
479 | |
480 /* if not logged in, there is nothing to do */ | |
481 if ( !( session->flags & MXIT_FLAG_LOGGEDIN ) ) | |
482 return; | |
483 | |
484 /* pinging is only for socket connections (HTTP does polling) */ | |
485 if ( session->http ) | |
486 return; | |
487 | |
488 if ( session->last_tx <= time( NULL ) - MXIT_PING_INTERVAL ) { | |
489 /* | |
490 * this connection has been idle for too long, better ping | |
491 * the server before it kills our connection. | |
492 */ | |
493 mxit_send_ping( session ); | |
494 } | |
495 } | |
496 | |
497 | |
498 /*------------------------------------------------------------------------ | |
499 * Set or clear our Buddy icon. | |
500 * | |
501 * @param gc The connection object | |
502 * @param img The buddy icon data | |
503 */ | |
504 static void mxit_set_buddy_icon( PurpleConnection *gc, PurpleStoredImage *img ) | |
505 { | |
506 struct MXitSession* session = (struct MXitSession*) gc->proto_data; | |
507 | |
508 if ( img == NULL ) | |
509 mxit_set_avatar( session, NULL, 0 ); | |
510 else | |
511 mxit_set_avatar( session, purple_imgstore_get_data( img ), purple_imgstore_get_size( img ) ); | |
512 } | |
513 | |
514 | |
515 /*------------------------------------------------------------------------ | |
516 * Request profile information for another MXit contact. | |
517 * | |
518 * @param gc The connection object | |
519 * @param who The username of the contact. | |
520 */ | |
521 static void mxit_get_info( PurpleConnection *gc, const char *who ) | |
522 { | |
523 struct MXitSession* session = (struct MXitSession*) gc->proto_data; | |
524 const char* profilelist[] = { CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_HIDENUMBER, CP_PROFILE_FULLNAME, | |
525 CP_PROFILE_TITLE, CP_PROFILE_FIRSTNAME, CP_PROFILE_LASTNAME, CP_PROFILE_EMAIL }; | |
526 | |
527 purple_debug_info( MXIT_PLUGIN_ID, "mxit_get_info: '%s'\n", who ); | |
528 | |
529 | |
530 /* send profile request */ | |
531 mxit_send_extprofile_request( session, who, ARRAY_SIZE( profilelist ), profilelist ); | |
532 } | |
533 | |
534 | |
535 /*------------------------------------------------------------------------ | |
536 * Return a list of labels to be used by Pidgin for assisting the user. | |
537 */ | |
538 static GHashTable* mxit_get_text_table( PurpleAccount* acc ) | |
539 { | |
540 GHashTable* table; | |
541 | |
542 table = g_hash_table_new( g_str_hash, g_str_equal ); | |
543 | |
544 g_hash_table_insert( table, "login_label", _( "Your Mobile Number..." ) ); | |
545 | |
546 return table; | |
547 } | |
548 | |
549 /*========================================================================================================================*/ | |
550 | |
551 static PurplePluginProtocolInfo proto_info = { | |
552 OPT_PROTO_REGISTER_NOSCREENNAME | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_IM_IMAGE, /* options */ | |
553 NULL, /* user_splits */ | |
554 NULL, /* protocol_options */ | |
555 { /* icon_spec */ | |
556 "png", /* format */ | |
557 32, 32, /* min width & height */ | |
558 MXIT_AVATAR_SIZE, /* max width */ | |
559 MXIT_AVATAR_SIZE, /* max height */ | |
560 100000, /* max filezize */ | |
561 PURPLE_ICON_SCALE_SEND | PURPLE_ICON_SCALE_DISPLAY /* scaling rules */ | |
562 }, | |
563 mxit_list_icon, /* list_icon */ | |
564 mxit_list_emblem, /* list_emblem */ | |
565 mxit_status_text, /* status_text */ | |
566 mxit_tooltip, /* tooltip_text */ | |
567 mxit_status_types, /* status types [roster.c] */ | |
568 NULL, /* blist_node_menu */ | |
569 mxit_chat_info, /* chat_info [multimx.c] */ | |
570 NULL, /* chat_info_defaults */ | |
571 mxit_login, /* login [login.c] */ | |
572 mxit_close, /* close */ | |
573 mxit_send_im, /* send_im */ | |
574 NULL, /* set_info */ | |
575 NULL, /* send_typing */ | |
576 mxit_get_info, /* get_info */ | |
577 mxit_set_status, /* set_status */ | |
578 NULL, /* set_idle */ | |
579 NULL, /* change_passwd */ | |
580 mxit_add_buddy, /* add_buddy [roster.c] */ | |
581 NULL, /* add_buddies */ | |
582 mxit_remove_buddy, /* remove_buddy [roster.c] */ | |
583 NULL, /* remove_buddies */ | |
584 NULL, /* add_permit */ | |
585 NULL, /* add_deny */ | |
586 NULL, /* rem_permit */ | |
587 NULL, /* rem_deny */ | |
588 NULL, /* set_permit_deny */ | |
589 mxit_chat_join, /* join_chat [multimx.c] */ | |
590 mxit_chat_reject, /* reject chat invite [multimx.c] */ | |
591 mxit_chat_name, /* get_chat_name [multimx.c] */ | |
592 mxit_chat_invite, /* chat_invite [multimx.c] */ | |
593 mxit_chat_leave, /* chat_leave [multimx.c] */ | |
594 NULL, /* chat_whisper */ | |
595 mxit_chat_send, /* chat_send [multimx.c] */ | |
596 mxit_keepalive, /* keepalive */ | |
597 mxit_register, /* register_user */ | |
598 NULL, /* get_cb_info */ | |
599 NULL, /* get_cb_away */ | |
600 mxit_buddy_alias, /* alias_buddy [roster.c] */ | |
601 mxit_buddy_group, /* group_buddy [roster.c] */ | |
602 mxit_rename_group, /* rename_group [roster.c] */ | |
603 mxit_free_buddy, /* buddy_free */ | |
604 NULL, /* convo_closed */ | |
605 NULL, /* normalize */ | |
606 mxit_set_buddy_icon, /* set_buddy_icon */ | |
607 NULL, /* remove_group */ // TODO: Add function to move all contacts out of this group (cmd=30 - remove group)? | |
608 NULL, /* get_cb_real_name */ | |
609 NULL, /* set_chat_topic */ | |
610 NULL, /* find_blist_chat */ | |
611 NULL, /* roomlist_get_list */ | |
612 NULL, /* roomlist_cancel */ | |
613 NULL, /* roomlist_expand_category */ | |
614 mxit_xfer_enabled, /* can_receive_file [filexfer.c] */ | |
615 mxit_xfer_tx, /* send_file [filexfer.c */ | |
616 mxit_xfer_new, /* new_xfer [filexfer.c] */ | |
617 mxit_offline_message, /* offline_message */ | |
618 NULL, /* whiteboard_prpl_ops */ | |
619 NULL, /* send_raw */ | |
620 NULL, /* roomlist_room_serialize */ | |
621 NULL, /* unregister_user */ | |
622 NULL, /* send_attention */ | |
623 NULL, /* attention_types */ | |
624 sizeof( PurplePluginProtocolInfo ), /* struct_size */ | |
625 mxit_get_text_table, /* get_account_text_table */ | |
626 NULL, | |
627 NULL | |
628 }; | |
629 | |
630 | |
631 static PurplePluginInfo plugin_info = { | |
632 PURPLE_PLUGIN_MAGIC, /* purple magic, this must always be PURPLE_PLUGIN_MAGIC */ | |
633 PURPLE_MAJOR_VERSION, /* libpurple version */ | |
634 PURPLE_MINOR_VERSION, /* libpurple version */ | |
635 PURPLE_PLUGIN_PROTOCOL, /* plugin type (connecting to another network) */ | |
636 NULL, /* UI requirement (NULL for core plugin) */ | |
637 0, /* plugin flags (zero is default) */ | |
638 NULL, /* plugin dependencies (set this value to NULL no matter what) */ | |
639 PURPLE_PRIORITY_DEFAULT, /* libpurple priority */ | |
640 | |
641 MXIT_PLUGIN_ID, /* plugin id (must be unique) */ | |
642 MXIT_PLUGIN_NAME, /* plugin name (this will be displayed in the UI) */ | |
643 MXIT_PLUGIN_VERSION, /* version of the plugin */ | |
644 | |
645 MXIT_PLUGIN_SUMMARY, /* short summary of the plugin */ | |
646 MXIT_PLUGIN_DESC, /* description of the plugin (can be long) */ | |
647 MXIT_PLUGIN_EMAIL, /* plugin author name and email address */ | |
648 MXIT_PLUGIN_WWW, /* plugin website (to find new versions and reporting of bugs) */ | |
649 | |
650 NULL, /* function pointer for loading the plugin */ | |
651 NULL, /* function pointer for unloading the plugin */ | |
652 NULL, /* function pointer for destroying the plugin */ | |
653 | |
654 NULL, /* pointer to an UI-specific struct */ | |
655 &proto_info, /* pointer to either a PurplePluginLoaderInfo or PurplePluginProtocolInfo struct */ | |
656 NULL, /* pointer to a PurplePluginUiInfo struct */ | |
657 mxit_actions, /* function pointer where you can define plugin-actions */ | |
658 | |
659 /* padding */ | |
660 NULL, /* pointer reserved for future use */ | |
661 NULL, /* pointer reserved for future use */ | |
662 NULL, /* pointer reserved for future use */ | |
663 NULL /* pointer reserved for future use */ | |
664 }; | |
665 | |
666 | |
667 /*------------------------------------------------------------------------ | |
668 * Initialising the MXit plugin. | |
669 * | |
670 * @param plugin The plugin object | |
671 */ | |
672 static void init_plugin( PurplePlugin* plugin ) | |
673 { | |
674 PurpleAccountOption* option; | |
675 | |
676 purple_debug_info( MXIT_PLUGIN_ID, "Loading MXit libPurple plugin...\n" ); | |
677 | |
678 /* Configuration options */ | |
679 | |
680 /* WAP server (reference: "libpurple/accountopt.h") */ | |
681 option = purple_account_option_string_new( _( "WAP Server" ), MXIT_CONFIG_WAPSERVER, DEFAULT_WAPSITE ); | |
682 proto_info.protocol_options = g_list_append( proto_info.protocol_options, option ); | |
683 | |
684 option = purple_account_option_bool_new( _( "Connect via HTTP" ), MXIT_CONFIG_USE_HTTP, FALSE ); | |
685 proto_info.protocol_options = g_list_append( proto_info.protocol_options, option ); | |
686 | |
687 option = purple_account_option_bool_new( _( "Enable splash-screen popup" ), MXIT_CONFIG_SPLASHPOPUP, FALSE ); | |
688 proto_info.protocol_options = g_list_append( proto_info.protocol_options, option ); | |
689 | |
690 g_assert( sizeof( struct raw_chunk ) == 5 ); | |
691 } | |
692 | |
693 PURPLE_INIT_PLUGIN( mxit, init_plugin, plugin_info ); | |
694 |