Mercurial > pidgin
comparison libpurple/protocols/oscar/oscar.c @ 27999:901476dc70b9
propagate from branch 'im.pidgin.pidgin' (head dd712fa84e46b2d78adf28e914d3e1a5c18a5154)
to branch 'im.pidgin.cpw.darkrain42.2.6.1' (head bbfae195c9c51fc001abbf89a084b54d4ec4b549)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Wed, 19 Aug 2009 00:37:01 +0000 |
parents | 1f329bdc91ab de7bbdcb695b |
children | 0a587ffcab9b |
comparison
equal
deleted
inserted
replaced
27991:2253903841a6 | 27999:901476dc70b9 |
---|---|
158 static int purple_parse_offgoing (OscarData *, FlapConnection *, FlapFrame *, ...); | 158 static int purple_parse_offgoing (OscarData *, FlapConnection *, FlapFrame *, ...); |
159 static int purple_parse_incoming_im(OscarData *, FlapConnection *, FlapFrame *, ...); | 159 static int purple_parse_incoming_im(OscarData *, FlapConnection *, FlapFrame *, ...); |
160 static int purple_parse_misses (OscarData *, FlapConnection *, FlapFrame *, ...); | 160 static int purple_parse_misses (OscarData *, FlapConnection *, FlapFrame *, ...); |
161 static int purple_parse_clientauto (OscarData *, FlapConnection *, FlapFrame *, ...); | 161 static int purple_parse_clientauto (OscarData *, FlapConnection *, FlapFrame *, ...); |
162 static int purple_parse_userinfo (OscarData *, FlapConnection *, FlapFrame *, ...); | 162 static int purple_parse_userinfo (OscarData *, FlapConnection *, FlapFrame *, ...); |
163 static int purple_got_infoblock (OscarData *, FlapConnection *, FlapFrame *, ...); | |
164 static int purple_parse_motd (OscarData *, FlapConnection *, FlapFrame *, ...); | 163 static int purple_parse_motd (OscarData *, FlapConnection *, FlapFrame *, ...); |
165 static int purple_chatnav_info (OscarData *, FlapConnection *, FlapFrame *, ...); | 164 static int purple_chatnav_info (OscarData *, FlapConnection *, FlapFrame *, ...); |
166 static int purple_conv_chat_join (OscarData *, FlapConnection *, FlapFrame *, ...); | 165 static int purple_conv_chat_join (OscarData *, FlapConnection *, FlapFrame *, ...); |
167 static int purple_conv_chat_leave (OscarData *, FlapConnection *, FlapFrame *, ...); | 166 static int purple_conv_chat_leave (OscarData *, FlapConnection *, FlapFrame *, ...); |
168 static int purple_conv_chat_info_update (OscarData *, FlapConnection *, FlapFrame *, ...); | 167 static int purple_conv_chat_info_update (OscarData *, FlapConnection *, FlapFrame *, ...); |
810 gchar *message = NULL, *itmsurl = NULL, *tmp; | 809 gchar *message = NULL, *itmsurl = NULL, *tmp; |
811 gboolean is_away; | 810 gboolean is_away; |
812 | 811 |
813 od = purple_connection_get_protocol_data(gc); | 812 od = purple_connection_get_protocol_data(gc); |
814 | 813 |
815 if (userinfo == NULL) | 814 if (b == NULL && userinfo == NULL) |
816 userinfo = aim_locate_finduserinfo(od, purple_buddy_get_name(b)); | |
817 | |
818 if ((user_info == NULL) || ((b == NULL) && (userinfo == NULL))) | |
819 return; | 815 return; |
820 | 816 |
821 if (b == NULL) | 817 if (b == NULL) |
822 b = purple_find_buddy(purple_connection_get_account(gc), userinfo->bn); | 818 b = purple_find_buddy(purple_connection_get_account(gc), userinfo->bn); |
819 else | |
820 userinfo = aim_locate_finduserinfo(od, purple_buddy_get_name(b)); | |
823 | 821 |
824 if (b) { | 822 if (b) { |
825 presence = purple_buddy_get_presence(b); | 823 presence = purple_buddy_get_presence(b); |
826 status = purple_presence_get_active_status(presence); | 824 status = purple_presence_get_active_status(presence); |
827 | 825 } |
828 message = g_strdup(purple_status_get_attr_string(status, "message")); | 826 |
829 itmsurl = g_strdup(purple_status_get_attr_string(status, "itmsurl")); | 827 /* If we have both b and userinfo we favor userinfo, because if we're |
830 | 828 viewing someone's profile then we want the HTML away message, and |
831 } else { | 829 the "message" attribute of the status contains only the plaintext |
832 /* This is an OSCAR contact for whom we don't have a PurpleBuddy but do have information. */ | 830 message. */ |
831 if (userinfo) { | |
833 if ((userinfo->flags & AIM_FLAG_AWAY)) { | 832 if ((userinfo->flags & AIM_FLAG_AWAY)) { |
834 /* Away message? */ | 833 /* Away message? */ |
835 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | 834 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { |
836 tmp = oscar_encoding_extract(userinfo->away_encoding); | 835 tmp = oscar_encoding_extract(userinfo->away_encoding); |
837 message = oscar_encoding_to_utf8(account, tmp, userinfo->away, | 836 message = oscar_encoding_to_utf8(account, tmp, userinfo->away, |
848 if (userinfo->itmsurl && (userinfo->itmsurl[0] != '\0')) | 847 if (userinfo->itmsurl && (userinfo->itmsurl[0] != '\0')) |
849 itmsurl = oscar_encoding_to_utf8(account, userinfo->itmsurl_encoding, | 848 itmsurl = oscar_encoding_to_utf8(account, userinfo->itmsurl_encoding, |
850 userinfo->itmsurl, userinfo->itmsurl_len); | 849 userinfo->itmsurl, userinfo->itmsurl_len); |
851 #endif | 850 #endif |
852 } | 851 } |
852 } else { | |
853 message = g_strdup(purple_status_get_attr_string(status, "message")); | |
854 itmsurl = g_strdup(purple_status_get_attr_string(status, "itmsurl")); | |
853 } | 855 } |
854 | 856 |
855 is_away = ((status && !purple_status_is_available(status)) || | 857 is_away = ((status && !purple_status_is_available(status)) || |
856 (userinfo && (userinfo->flags & AIM_FLAG_AWAY))); | 858 (userinfo && (userinfo->flags & AIM_FLAG_AWAY))); |
857 | 859 |
914 message = tmp; | 916 message = tmp; |
915 } else { | 917 } else { |
916 g_free(message); | 918 g_free(message); |
917 message = g_strdup(_("Offline")); | 919 message = g_strdup(_("Offline")); |
918 } | 920 } |
919 | |
920 } | 921 } |
921 | 922 |
922 purple_notify_user_info_add_pair(user_info, _("Status"), message); | 923 purple_notify_user_info_add_pair(user_info, _("Status"), message); |
923 g_free(message); | 924 g_free(message); |
924 } | 925 } |
1476 oscar_data_addhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_ALIAS, purple_icqalias, 0); | 1477 oscar_data_addhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_ALIAS, purple_icqalias, 0); |
1477 oscar_data_addhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_INFO, purple_icqinfo, 0); | 1478 oscar_data_addhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_INFO, purple_icqinfo, 0); |
1478 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_RIGHTSINFO, purple_parse_locaterights, 0); | 1479 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_RIGHTSINFO, purple_parse_locaterights, 0); |
1479 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_USERINFO, purple_parse_userinfo, 0); | 1480 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_USERINFO, purple_parse_userinfo, 0); |
1480 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_ERROR, purple_parse_locerr, 0); | 1481 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_ERROR, purple_parse_locerr, 0); |
1481 oscar_data_addhandler(od, SNAC_FAMILY_LOCATE, SNAC_SUBTYPE_LOCATE_GOTINFOBLOCK, purple_got_infoblock, 0); | |
1482 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0001, purple_parse_genericerr, 0); | 1482 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0001, purple_parse_genericerr, 0); |
1483 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x000f, purple_selfinfo, 0); | 1483 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x000f, purple_selfinfo, 0); |
1484 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x001f, purple_memrequest, 0); | 1484 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x001f, purple_memrequest, 0); |
1485 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0021, oscar_icon_req,0); | 1485 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, 0x0021, oscar_icon_req,0); |
1486 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_RATECHANGE, purple_parse_ratechange, 0); | 1486 oscar_data_addhandler(od, SNAC_FAMILY_OSERVICE, SNAC_SUBTYPE_OSERVICE_RATECHANGE, purple_parse_ratechange, 0); |
2136 info = va_arg(ap, aim_userinfo_t *); | 2136 info = va_arg(ap, aim_userinfo_t *); |
2137 va_end(ap); | 2137 va_end(ap); |
2138 | 2138 |
2139 g_return_val_if_fail(info != NULL, 1); | 2139 g_return_val_if_fail(info != NULL, 1); |
2140 g_return_val_if_fail(info->bn != NULL, 1); | 2140 g_return_val_if_fail(info->bn != NULL, 1); |
2141 | |
2142 /* | |
2143 * If this is an AIM buddy and their name has formatting, set their | |
2144 * server alias. | |
2145 */ | |
2146 if (!oscar_util_valid_name_icq(info->bn)) { | |
2147 gboolean bn_has_formatting = FALSE; | |
2148 char *c; | |
2149 for (c = info->bn; *c != '\0'; c++) { | |
2150 if (!islower(*c)) { | |
2151 bn_has_formatting = TRUE; | |
2152 break; | |
2153 } | |
2154 } | |
2155 serv_got_alias(gc, info->bn, | |
2156 bn_has_formatting ? info->bn : NULL); | |
2157 } | |
2141 | 2158 |
2142 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { | 2159 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
2143 if (info->flags & AIM_FLAG_AWAY) | 2160 if (info->flags & AIM_FLAG_AWAY) |
2144 buddy_is_away = TRUE; | 2161 buddy_is_away = TRUE; |
2145 } | 2162 } |
3285 } | 3302 } |
3286 | 3303 |
3287 oscar_user_info_append_extra_info(gc, user_info, NULL, userinfo); | 3304 oscar_user_info_append_extra_info(gc, user_info, NULL, userinfo); |
3288 | 3305 |
3289 if ((userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) && !oscar_util_valid_name_sms(userinfo->bn)) { | 3306 if ((userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) && !oscar_util_valid_name_sms(userinfo->bn)) { |
3290 /* An SMS contact is always online; its Online Since valid is not useful */ | 3307 /* An SMS contact is always online; its Online Since value is not useful */ |
3291 time_t t = userinfo->onlinesince; | 3308 time_t t = userinfo->onlinesince; |
3292 oscar_user_info_add_pair(user_info, _("Online Since"), purple_date_format_full(localtime(&t))); | 3309 oscar_user_info_add_pair(user_info, _("Online Since"), purple_date_format_full(localtime(&t))); |
3293 } | 3310 } |
3294 | 3311 |
3295 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | 3312 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { |
3324 purple_notify_user_info_add_pair(user_info, NULL, tmp); | 3341 purple_notify_user_info_add_pair(user_info, NULL, tmp); |
3325 g_free(tmp); | 3342 g_free(tmp); |
3326 | 3343 |
3327 purple_notify_userinfo(gc, userinfo->bn, user_info, NULL, NULL); | 3344 purple_notify_userinfo(gc, userinfo->bn, user_info, NULL, NULL); |
3328 purple_notify_user_info_destroy(user_info); | 3345 purple_notify_user_info_destroy(user_info); |
3329 | |
3330 return 1; | |
3331 } | |
3332 | |
3333 static int purple_got_infoblock(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) | |
3334 { | |
3335 PurpleConnection *gc = od->gc; | |
3336 PurpleAccount *account = purple_connection_get_account(gc); | |
3337 PurpleBuddy *b; | |
3338 PurplePresence *presence; | |
3339 PurpleStatus *status; | |
3340 gchar *message = NULL; | |
3341 | |
3342 va_list ap; | |
3343 aim_userinfo_t *userinfo; | |
3344 | |
3345 va_start(ap, fr); | |
3346 userinfo = va_arg(ap, aim_userinfo_t *); | |
3347 va_end(ap); | |
3348 | |
3349 b = purple_find_buddy(account, userinfo->bn); | |
3350 if (b == NULL) | |
3351 return 1; | |
3352 | |
3353 if (!oscar_util_valid_name_icq(userinfo->bn)) | |
3354 { | |
3355 if (strcmp(purple_buddy_get_name(b), userinfo->bn) != 0) | |
3356 serv_got_alias(gc, purple_buddy_get_name(b), userinfo->bn); | |
3357 else | |
3358 serv_got_alias(gc, purple_buddy_get_name(b), NULL); | |
3359 } | |
3360 | |
3361 presence = purple_buddy_get_presence(b); | |
3362 status = purple_presence_get_active_status(presence); | |
3363 | |
3364 if (purple_status_is_online(status) && !purple_status_is_available(status) && | |
3365 userinfo->flags & AIM_FLAG_AWAY && userinfo->away_len > 0 && | |
3366 userinfo->away != NULL && userinfo->away_encoding != NULL) | |
3367 { | |
3368 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); | |
3369 message = oscar_encoding_to_utf8(account, charset, | |
3370 userinfo->away, | |
3371 userinfo->away_len); | |
3372 g_free(charset); | |
3373 purple_prpl_got_user_status(account, userinfo->bn, | |
3374 purple_status_get_id(status), | |
3375 "message", message, NULL); | |
3376 g_free(message); | |
3377 } | |
3378 | 3346 |
3379 return 1; | 3347 return 1; |
3380 } | 3348 } |
3381 | 3349 |
3382 static int purple_parse_motd(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) | 3350 static int purple_parse_motd(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) |