| 84 * @param username The username of the contact |
84 * @param username The username of the contact |
| 85 */ |
85 */ |
| 86 void mxit_strip_domain( char* username ) |
86 void mxit_strip_domain( char* username ) |
| 87 { |
87 { |
| 88 if ( g_str_has_suffix( username, "@m" ) ) |
88 if ( g_str_has_suffix( username, "@m" ) ) |
| 89 username[ strlen(username) - 2 ] = '\0'; |
89 username[ strlen( username ) - 2 ] = '\0'; |
| 90 } |
90 } |
| 91 |
91 |
| 92 |
92 |
| 93 /*------------------------------------------------------------------------ |
93 /*------------------------------------------------------------------------ |
| 94 * Dump a byte buffer to the console for debugging purposes. |
94 * Dump a byte buffer to the console for debugging purposes. |
| 705 unsigned int features = MXIT_CP_FEATURES; |
705 unsigned int features = MXIT_CP_FEATURES; |
| 706 |
706 |
| 707 locale = purple_account_get_string( session->acc, MXIT_CONFIG_LOCALE, MXIT_DEFAULT_LOCALE ); |
707 locale = purple_account_get_string( session->acc, MXIT_CONFIG_LOCALE, MXIT_DEFAULT_LOCALE ); |
| 708 |
708 |
| 709 /* Voice and Video supported */ |
709 /* Voice and Video supported */ |
| 710 if (mxit_audio_enabled() && mxit_video_enabled()) |
710 if ( mxit_audio_enabled() && mxit_video_enabled() ) |
| 711 features |= (MXIT_CF_VOICE | MXIT_CF_VIDEO); |
711 features |= ( MXIT_CF_VOICE | MXIT_CF_VIDEO ); |
| 712 else if (mxit_audio_enabled()) |
712 else if ( mxit_audio_enabled() ) |
| 713 features |= MXIT_CF_VOICE; |
713 features |= MXIT_CF_VOICE; |
| 714 |
714 |
| 715 /* generate client version string (eg, P-2.7.10-Y-PURPLE) */ |
715 /* generate client version string (eg, P-2.7.10-Y-PURPLE) */ |
| 716 clientVersion = g_strdup_printf( "%c-%i.%i.%i-%s-%s", MXIT_CP_DISTCODE, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_MICRO_VERSION, MXIT_CP_ARCH, MXIT_CP_PLATFORM ); |
716 clientVersion = g_strdup_printf( "%c-%i.%i.%i-%s-%s", MXIT_CP_DISTCODE, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_MICRO_VERSION, MXIT_CP_ARCH, MXIT_CP_PLATFORM ); |
| 717 |
717 |
| 749 unsigned int features = MXIT_CP_FEATURES; |
749 unsigned int features = MXIT_CP_FEATURES; |
| 750 |
750 |
| 751 locale = purple_account_get_string( session->acc, MXIT_CONFIG_LOCALE, MXIT_DEFAULT_LOCALE ); |
751 locale = purple_account_get_string( session->acc, MXIT_CONFIG_LOCALE, MXIT_DEFAULT_LOCALE ); |
| 752 |
752 |
| 753 /* Voice and Video supported */ |
753 /* Voice and Video supported */ |
| 754 if (mxit_audio_enabled() && mxit_video_enabled()) |
754 if ( mxit_audio_enabled() && mxit_video_enabled() ) |
| 755 features |= (MXIT_CF_VOICE | MXIT_CF_VIDEO); |
755 features |= ( MXIT_CF_VOICE | MXIT_CF_VIDEO ); |
| 756 else if (mxit_audio_enabled()) |
756 else if (mxit_audio_enabled()) |
| 757 features |= MXIT_CF_VOICE; |
757 features |= MXIT_CF_VOICE; |
| 758 |
758 |
| 759 /* generate client version string (eg, P-2.7.10-Y-PURPLE) */ |
759 /* generate client version string (eg, P-2.7.10-Y-PURPLE) */ |
| 760 clientVersion = g_strdup_printf( "%c-%i.%i.%i-%s-%s", MXIT_CP_DISTCODE, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_MICRO_VERSION, MXIT_CP_ARCH, MXIT_CP_PLATFORM ); |
760 clientVersion = g_strdup_printf( "%c-%i.%i.%i-%s-%s", MXIT_CP_DISTCODE, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_MICRO_VERSION, MXIT_CP_ARCH, MXIT_CP_PLATFORM ); |
| 1148 * @param session The MXit session object |
1148 * @param session The MXit session object |
| 1149 * @param to The username of the original sender (ie, recipient of the event) |
1149 * @param to The username of the original sender (ie, recipient of the event) |
| 1150 * @param id The identifier of the event (received in message) |
1150 * @param id The identifier of the event (received in message) |
| 1151 * @param event Identified the type of event |
1151 * @param event Identified the type of event |
| 1152 */ |
1152 */ |
| 1153 void mxit_send_msgevent( struct MXitSession* session, const char* to, const char* id, int event) |
1153 void mxit_send_msgevent( struct MXitSession* session, const char* to, const char* id, int event ) |
| 1154 { |
1154 { |
| 1155 char data[CP_MAX_PACKET]; |
1155 char data[CP_MAX_PACKET]; |
| 1156 int datalen; |
1156 int datalen; |
| 1157 |
1157 |
| 1158 purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_msgevent: to=%s id=%s event=%i\n", to, id, event ); |
1158 purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_msgevent: to=%s id=%s event=%i\n", to, id, event ); |
| 2059 static void mxit_parse_cmd_msgevent( struct MXitSession* session, struct record** records, int rcount ) |
2059 static void mxit_parse_cmd_msgevent( struct MXitSession* session, struct record** records, int rcount ) |
| 2060 { |
2060 { |
| 2061 int event; |
2061 int event; |
| 2062 |
2062 |
| 2063 /* |
2063 /* |
| 2064 * contactAddress \1 dateTime \1 id \1 event |
2064 * contactAddress \1 dateTime \1 id \1 event |
| 2065 */ |
2065 */ |
| 2066 |
2066 |
| 2067 /* strip off dummy domain */ |
2067 /* strip off dummy domain */ |
| 2068 mxit_strip_domain( records[0]->fields[0]->data ); |
2068 mxit_strip_domain( records[0]->fields[0]->data ); |
| 2069 |
2069 |
| 2200 /* show the profile */ |
2200 /* show the profile */ |
| 2201 mxit_show_profile( session, chunk.mxitid, contact->profile ); |
2201 mxit_show_profile( session, chunk.mxitid, contact->profile ); |
| 2202 } |
2202 } |
| 2203 else { |
2203 else { |
| 2204 /* this is a contact's avatar, so update it */ |
2204 /* this is a contact's avatar, so update it */ |
| 2205 purple_buddy_icons_set_for_user( session->acc, chunk.mxitid, g_memdup( chunk.data, chunk.length), chunk.length, chunk.avatarid ); |
2205 purple_buddy_icons_set_for_user( session->acc, chunk.mxitid, g_memdup( chunk.data, chunk.length ), chunk.length, chunk.avatarid ); |
| 2206 } |
2206 } |
| 2207 } |
2207 } |
| 2208 } |
2208 } |
| 2209 break; |
2209 break; |
| 2210 |
2210 |
| 2339 mxit_parse_cmd_contact( session, &packet->records[2], packet->rcount - 3 ); |
2339 mxit_parse_cmd_contact( session, &packet->records[2], packet->rcount - 3 ); |
| 2340 break; |
2340 break; |
| 2341 |
2341 |
| 2342 case CP_CMD_PRESENCE : |
2342 case CP_CMD_PRESENCE : |
| 2343 /* presence update */ |
2343 /* presence update */ |
| 2344 mxit_parse_cmd_presence(session, &packet->records[2], packet->rcount - 3 ); |
2344 mxit_parse_cmd_presence( session, &packet->records[2], packet->rcount - 3 ); |
| 2345 break; |
2345 break; |
| 2346 |
2346 |
| 2347 case CP_CMD_RX_MSG : |
2347 case CP_CMD_RX_MSG : |
| 2348 /* incoming message (no bogus record) */ |
2348 /* incoming message (no bogus record) */ |
| 2349 mxit_parse_cmd_message( session, &packet->records[2], packet->rcount - 2 ); |
2349 mxit_parse_cmd_message( session, &packet->records[2], packet->rcount - 2 ); |
| 2878 session->flags &= ~MXIT_FLAG_CONNECTED; |
2878 session->flags &= ~MXIT_FLAG_CONNECTED; |
| 2879 |
2879 |
| 2880 /* cancel all outstanding async calls */ |
2880 /* cancel all outstanding async calls */ |
| 2881 while ( session->async_calls ) { |
2881 while ( session->async_calls ) { |
| 2882 purple_util_fetch_url_cancel( session->async_calls->data ); |
2882 purple_util_fetch_url_cancel( session->async_calls->data ); |
| 2883 session->async_calls = g_slist_delete_link(session->async_calls, session->async_calls); |
2883 session->async_calls = g_slist_delete_link( session->async_calls, session->async_calls ); |
| 2884 } |
2884 } |
| 2885 |
2885 |
| 2886 /* remove the input cb function */ |
2886 /* remove the input cb function */ |
| 2887 if ( session->con->inpa ) { |
2887 if ( session->con->inpa ) { |
| 2888 purple_input_remove( session->con->inpa ); |
2888 purple_input_remove( session->con->inpa ); |