Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 7334:83e8faa7f6d5
[gaim-migrate @ 7922]
Add the ability to view users with secure IM enabled on AIM. They have a
lock icon overlay. Also some other small changes and minor bandwidth
usage reduction. I'm Brian Fellows!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 26 Oct 2003 07:35:16 +0000 |
parents | 3bcd867c22f3 |
children | 566eba9a2b2c |
comparison
equal
deleted
inserted
replaced
7333:6338cb1768ea | 7334:83e8faa7f6d5 |
---|---|
57 | 57 |
58 #define OSCAR_CONNECT_STEPS 6 | 58 #define OSCAR_CONNECT_STEPS 6 |
59 | 59 |
60 static GaimPlugin *my_protocol = NULL; | 60 static GaimPlugin *my_protocol = NULL; |
61 | 61 |
62 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE; | 62 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
63 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE; | 63 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
64 | 64 |
65 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; | 65 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
66 static fu8_t features_icq[] = {0x01, 0x06}; | 66 static fu8_t features_icq[] = {0x01, 0x06}; |
67 | 67 |
68 typedef struct _OscarData OscarData; | 68 typedef struct _OscarData OscarData; |
3120 break; | 3120 break; |
3121 case AIM_CAPS_HIPTOP: | 3121 case AIM_CAPS_HIPTOP: |
3122 tmp = _("Hiptop"); | 3122 tmp = _("Hiptop"); |
3123 break; | 3123 break; |
3124 case AIM_CAPS_SECUREIM: | 3124 case AIM_CAPS_SECUREIM: |
3125 tmp = _("Secure IM"); | 3125 tmp = _("Security Enabled"); |
3126 break; | 3126 break; |
3127 default: | 3127 default: |
3128 tmp = NULL; | 3128 tmp = NULL; |
3129 break; | 3129 break; |
3130 } | 3130 } |
3676 GaimConnection *gc = sess->aux_data; | 3676 GaimConnection *gc = sess->aux_data; |
3677 | 3677 |
3678 aim_reqpersonalinfo(sess, fr->conn); | 3678 aim_reqpersonalinfo(sess, fr->conn); |
3679 | 3679 |
3680 #ifndef NOSSI | 3680 #ifndef NOSSI |
3681 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: requesting ssi list\n"); | 3681 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: requesting rights and list\n"); |
3682 aim_ssi_reqrights(sess); | 3682 aim_ssi_reqrights(sess); |
3683 aim_ssi_reqdata(sess); | 3683 aim_ssi_reqdata(sess); |
3684 #endif | 3684 #endif |
3685 | 3685 |
3686 aim_locate_reqrights(sess); | 3686 aim_locate_reqrights(sess); |
3687 aim_buddylist_reqrights(sess, fr->conn); | 3687 aim_buddylist_reqrights(sess, fr->conn); |
3688 aim_im_reqparams(sess); | 3688 aim_im_reqparams(sess); |
3689 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi? */ | 3689 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
3690 | 3690 |
3691 #ifdef NOSSI | 3691 #ifdef NOSSI |
3692 gaim_debug(GAIM_DEBUG_INFO, "oscar", "bos: requesting rights\n"); | |
3693 aim_bos_reqrights(sess, fr->conn); | |
3692 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); | 3694 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
3693 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | 3695 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); |
3694 #endif | 3696 #endif |
3695 | 3697 |
3696 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); | 3698 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
3787 "locate rights: max sig len = %d\n", maxsiglen); | 3789 "locate rights: max sig len = %d\n", maxsiglen); |
3788 | 3790 |
3789 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; | 3791 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
3790 | 3792 |
3791 if (od->icq) | 3793 if (od->icq) |
3792 aim_locate_setprofile(sess, NULL, NULL, 0, NULL, NULL, 0, caps_icq); | 3794 aim_locate_setcaps(od->sess, caps_icq); |
3793 else | 3795 else |
3794 oscar_set_info(gc, gc->account->user_info); | 3796 aim_locate_setcaps(od->sess, caps_aim); |
3797 oscar_set_info(gc, gc->account->user_info); | |
3795 | 3798 |
3796 return 1; | 3799 return 1; |
3797 } | 3800 } |
3798 | 3801 |
3799 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) { | 3802 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
3815 | 3818 |
3816 return 1; | 3819 return 1; |
3817 } | 3820 } |
3818 | 3821 |
3819 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { | 3822 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
3820 fu16_t maxpermits, maxdenies; | |
3821 va_list ap; | |
3822 GaimConnection *gc = sess->aux_data; | 3823 GaimConnection *gc = sess->aux_data; |
3823 OscarData *od = (OscarData *)gc->proto_data; | 3824 OscarData *od = (OscarData *)gc->proto_data; |
3825 va_list ap; | |
3826 fu16_t maxpermits, maxdenies; | |
3824 | 3827 |
3825 va_start(ap, fr); | 3828 va_start(ap, fr); |
3826 maxpermits = (fu16_t) va_arg(ap, unsigned int); | 3829 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
3827 maxdenies = (fu16_t) va_arg(ap, unsigned int); | 3830 maxdenies = (fu16_t) va_arg(ap, unsigned int); |
3828 va_end(ap); | 3831 va_end(ap); |
4413 _("You have probably requested to set your " | 4416 _("You have probably requested to set your " |
4414 "profile before the login procedure completed. " | 4417 "profile before the login procedure completed. " |
4415 "Your profile remains unset; try setting it " | 4418 "Your profile remains unset; try setting it " |
4416 "again when you are fully connected.")); | 4419 "again when you are fully connected.")); |
4417 | 4420 |
4418 if (od->icq) | 4421 if (!text) { |
4419 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, NULL, 0, caps_icq); | 4422 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); |
4420 else { | 4423 return; |
4421 if (!text) { | 4424 } |
4422 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, NULL, 0, caps_aim); | |
4423 return; | |
4424 } | |
4425 | 4425 |
4426 text_html = gaim_strdup_withhtml(text); | 4426 text_html = gaim_strdup_withhtml(text); |
4427 flags = oscar_encoding_check(text_html); | 4427 flags = oscar_encoding_check(text_html); |
4428 if (flags & AIM_IMFLAGS_UNICODE) { | 4428 if (flags & AIM_IMFLAGS_UNICODE) { |
4429 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | 4429 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
4430 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); | 4430 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); |
4431 g_free(msg); | 4431 g_free(msg); |
4432 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | 4432 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { |
4433 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | 4433 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
4434 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); | 4434 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); |
4435 g_free(msg); | 4435 g_free(msg); |
4436 } else { | 4436 } else { |
4437 msglen = strlen(text_html); | 4437 msglen = strlen(text_html); |
4438 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0, caps_aim); | 4438 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); |
4439 } | 4439 } |
4440 | 4440 |
4441 if (msglen > od->rights.maxsiglen) { | 4441 if (msglen > od->rights.maxsiglen) { |
4442 gchar *errstr; | 4442 gchar *errstr; |
4443 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | 4443 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " |
4444 "has been exceeded. Gaim has truncated it for you.", | 4444 "has been exceeded. Gaim has truncated it for you.", |
4445 "The maximum profile length of %d bytes " | 4445 "The maximum profile length of %d bytes " |
4446 "has been exceeded. Gaim has truncated it for you.", | 4446 "has been exceeded. Gaim has truncated it for you.", |
4447 od->rights.maxsiglen), od->rights.maxsiglen); | 4447 od->rights.maxsiglen), od->rights.maxsiglen); |
4448 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | 4448 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); |
4449 g_free(errstr); | 4449 g_free(errstr); |
4450 } | 4450 } |
4451 | 4451 |
4452 g_free(text_html); | 4452 g_free(text_html); |
4453 | |
4454 } | |
4455 | 4453 |
4456 return; | 4454 return; |
4457 } | 4455 } |
4458 | 4456 |
4459 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *text) | 4457 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *text) |
4475 g_free(gc->away); | 4473 g_free(gc->away); |
4476 gc->away = NULL; | 4474 gc->away = NULL; |
4477 } | 4475 } |
4478 | 4476 |
4479 if (!text) { | 4477 if (!text) { |
4480 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0, caps_aim); | 4478 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
4481 return; | 4479 return; |
4482 } | 4480 } |
4483 | 4481 |
4484 text_html = gaim_strdup_withhtml(text); | 4482 text_html = gaim_strdup_withhtml(text); |
4485 flags = oscar_encoding_check(text_html); | 4483 flags = oscar_encoding_check(text_html); |
4486 if (flags & AIM_IMFLAGS_UNICODE) { | 4484 if (flags & AIM_IMFLAGS_UNICODE) { |
4487 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | 4485 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
4488 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, | 4486 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
4489 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); | 4487 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
4490 g_free(msg); | 4488 g_free(msg); |
4491 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | 4489 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); |
4492 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | 4490 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { |
4493 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | 4491 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
4494 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, | 4492 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
4495 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); | 4493 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
4496 g_free(msg); | 4494 g_free(msg); |
4497 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); | 4495 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
4498 } else { | 4496 } else { |
4499 msglen = strlen(text_html); | 4497 msglen = strlen(text_html); |
4500 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, | 4498 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
4501 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen), caps_aim); | 4499 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
4502 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); | 4500 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
4503 } | 4501 } |
4504 | 4502 |
4505 if (msglen > od->rights.maxawaymsglen) { | 4503 if (msglen > od->rights.maxawaymsglen) { |
4506 gchar *errstr; | 4504 gchar *errstr; |
4626 } | 4624 } |
4627 aim_buddylist_set(od->sess, od->conn, buf); | 4625 aim_buddylist_set(od->sess, od->conn, buf); |
4628 #else | 4626 #else |
4629 if (od->sess->ssi.received_data) { | 4627 if (od->sess->ssi.received_data) { |
4630 while (buddies) { | 4628 while (buddies) { |
4631 GaimBuddy *buddy = gaim_find_buddy(gc->account, (const char *)buddies->data); | 4629 oscar_add_buddy(gc, (const char *)buddies->data, NULL); |
4632 GaimGroup *group = gaim_find_buddys_group(buddy); | |
4633 if (buddy && group) { | |
4634 gaim_debug(GAIM_DEBUG_INFO, "oscar", | |
4635 "ssi: adding buddy %s to group %s\n", (const char *)buddies->data, group->name); | |
4636 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); | |
4637 } | |
4638 buddies = buddies->next; | 4630 buddies = buddies->next; |
4639 } | 4631 } |
4640 } | 4632 } |
4641 #endif | 4633 #endif |
4642 } | 4634 } |
5321 return "aim"; | 5313 return "aim"; |
5322 } | 5314 } |
5323 | 5315 |
5324 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) | 5316 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
5325 { | 5317 { |
5318 GaimAccount *account = NULL; | |
5319 GaimConnection *gc = NULL; | |
5320 OscarData *od = NULL; | |
5326 char *emblems[4] = {NULL,NULL,NULL,NULL}; | 5321 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
5327 int i = 0; | 5322 int i = 0; |
5323 aim_userinfo_t *userinfo = NULL; | |
5324 | |
5325 if (b != NULL) | |
5326 account = b->account; | |
5327 if (account != NULL) | |
5328 gc = account->gc; | |
5329 if (gc != NULL) | |
5330 od = gc->proto_data; | |
5328 | 5331 |
5329 if (!GAIM_BUDDY_IS_ONLINE(b)) { | 5332 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
5330 GaimAccount *account; | |
5331 GaimConnection *gc; | |
5332 OscarData *od; | |
5333 char *gname; | 5333 char *gname; |
5334 if ((b->name) && (account = b->account) && (gc = account->gc) && | 5334 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
5335 (od = gc->proto_data) && (od->sess->ssi.received_data) && | |
5336 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && | 5335 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
5337 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | 5336 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { |
5338 emblems[i++] = "notauthorized"; | 5337 emblems[i++] = "notauthorized"; |
5339 } else { | 5338 } else { |
5340 emblems[i++] = "offline"; | 5339 emblems[i++] = "offline"; |
5369 emblems[i++] = "activebuddy"; | 5368 emblems[i++] = "activebuddy"; |
5370 if (b->uc & UC_HIPTOP && i < 4) | 5369 if (b->uc & UC_HIPTOP && i < 4) |
5371 emblems[i++] = "hiptop"; | 5370 emblems[i++] = "hiptop"; |
5372 /* if (b->uc & UC_UNCONFIRMED && i < 4) | 5371 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
5373 emblems[i++] = "unconfirmed"; */ | 5372 emblems[i++] = "unconfirmed"; */ |
5373 | |
5374 if ((i < 4) && (od != NULL)) { | |
5375 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
5376 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
5377 emblems[i++] = "secure"; | |
5378 } | |
5379 | |
5374 *se = emblems[0]; | 5380 *se = emblems[0]; |
5375 *sw = emblems[1]; | 5381 *sw = emblems[1]; |
5376 *nw = emblems[2]; | 5382 *nw = emblems[2]; |
5377 *ne = emblems[3]; | 5383 *ne = emblems[3]; |
5378 } | 5384 } |
5498 OscarData *od = gc->proto_data; | 5504 OscarData *od = gc->proto_data; |
5499 va_list ap; | 5505 va_list ap; |
5500 fu16_t type; | 5506 fu16_t type; |
5501 fu8_t flags = 0, length = 0; | 5507 fu8_t flags = 0, length = 0; |
5502 char *md5 = NULL; | 5508 char *md5 = NULL; |
5509 | |
5503 | 5510 |
5504 va_start(ap, fr); | 5511 va_start(ap, fr); |
5505 type = va_arg(ap, int); | 5512 type = va_arg(ap, int); |
5506 | 5513 |
5507 switch(type) { | 5514 switch(type) { |
6341 } | 6348 } |
6342 | 6349 |
6343 static void oscar_setavailmsg(GaimConnection *gc, char *text) { | 6350 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
6344 OscarData *od = (OscarData *)gc->proto_data; | 6351 OscarData *od = (OscarData *)gc->proto_data; |
6345 | 6352 |
6346 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0, 0); | 6353 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
6347 aim_srv_setavailmsg(od->sess, text); | 6354 aim_srv_setavailmsg(od->sess, text); |
6348 } | 6355 } |
6349 | 6356 |
6350 static void oscar_show_setavailmsg(GaimConnection *gc) | 6357 static void oscar_show_setavailmsg(GaimConnection *gc) |
6351 { | 6358 { |