# HG changeset patch # User Mark Doliner # Date 1073972677 0 # Node ID 697221d5d0ff8b58f352e5b8ba78b64960440ab1 # Parent 56b74730715ff85cb243ab9ba335d7bf385611e3 [gaim-migrate @ 8791] Give a nice little warning if you add an AIM or ICQ buddy with an invalid name. I'm thinking some of those bug reports on SF about "Could not add buddy with no name" are caused by this. Hopefully. Sometime before the next release I'll probably actually remove invalid people from the local list. Also recognize the WinAIM Video and Camera caps. committer: Tailor Script diff -r 56b74730715f -r 697221d5d0ff src/protocols/oscar/aim.h --- a/src/protocols/oscar/aim.h Tue Jan 13 03:02:59 2004 +0000 +++ b/src/protocols/oscar/aim.h Tue Jan 13 05:44:37 2004 +0000 @@ -1013,13 +1013,13 @@ } aim_userinfo_t; #define AIM_CAPS_BUDDYICON 0x00000001 -#define AIM_CAPS_VOICE 0x00000002 +#define AIM_CAPS_TALK 0x00000002 #define AIM_CAPS_DIRECTIM 0x00000004 #define AIM_CAPS_CHAT 0x00000008 #define AIM_CAPS_GETFILE 0x00000010 #define AIM_CAPS_SENDFILE 0x00000020 #define AIM_CAPS_GAMES 0x00000040 -#define AIM_CAPS_SAVESTOCKS 0x00000080 +#define AIM_CAPS_ADDINS 0x00000080 #define AIM_CAPS_SENDBUDDYLIST 0x00000100 #define AIM_CAPS_GAMES2 0x00000200 #define AIM_CAPS_ICQ_DIRECT 0x00000400 @@ -1038,7 +1038,9 @@ #define AIM_CAPS_GENERICUNKNOWN 0x00800000 #define AIM_CAPS_VIDEO 0x01000000 #define AIM_CAPS_ICHATAV 0x02000000 -#define AIM_CAPS_LAST 0x04000000 +#define AIM_CAPS_LIVEVIDEO 0x04000000 +#define AIM_CAPS_CAMERA 0x08000000 +#define AIM_CAPS_LAST 0x10000000 #define AIM_SENDMEMBLOCK_FLAG_ISREQUEST 0 #define AIM_SENDMEMBLOCK_FLAG_ISHASH 1 @@ -1472,6 +1474,7 @@ faim_export int aimutil_itemcnt(char *toSearch, char dl); faim_export char *aimutil_itemindex(char *toSearch, int theindex, char dl); +faim_export int aim_snvalid(const char *sn); faim_export int aim_snlen(const char *sn); faim_export int aim_sncmp(const char *sn1, const char *sn2); diff -r 56b74730715f -r 697221d5d0ff src/protocols/oscar/locate.c --- a/src/protocols/oscar/locate.c Tue Jan 13 03:02:59 2004 +0000 +++ b/src/protocols/oscar/locate.c Tue Jan 13 05:44:37 2004 +0000 @@ -46,6 +46,22 @@ {0x09, 0x46, 0x01, 0x00, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, + /* "Live Video" support in Windows AIM 5.5.3501 and newer */ + {AIM_CAPS_LIVEVIDEO, + {0x09, 0x46, 0x01, 0x01, 0x4c, 0x7f, 0x11, 0xd1, + 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, + + /* "Camera" support in Windows AIM 5.5.3501 and newer */ + {AIM_CAPS_CAMERA, + {0x09, 0x46, 0x01, 0x02, 0x4c, 0x7f, 0x11, 0xd1, + 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, + + /* In Windows AIM 5.5.3501 and newer */ + {AIM_CAPS_GENERICUNKNOWN, + {0x09, 0x46, 0x01, 0x03, 0x4c, 0x7f, 0x11, 0xd1, + 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, + + /* In iChatAV (version numbers...?) */ {AIM_CAPS_ICHATAV, {0x09, 0x46, 0x01, 0x05, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x45, 0x53, 0x54, 0x00}}, @@ -75,7 +91,7 @@ {0x09, 0x46, 0x13, 0x23, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, - {AIM_CAPS_VOICE, + {AIM_CAPS_TALK, {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, @@ -95,10 +111,7 @@ {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, - /* - * Windows AIM calls this "Add-ins," which is probably more accurate - */ - {AIM_CAPS_SAVESTOCKS, + {AIM_CAPS_ADDINS, {0x09, 0x46, 0x13, 0x47, 0x4c, 0x7f, 0x11, 0xd1, 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}}, diff -r 56b74730715f -r 697221d5d0ff src/protocols/oscar/msgcookie.c --- a/src/protocols/oscar/msgcookie.c Tue Jan 13 03:02:59 2004 +0000 +++ b/src/protocols/oscar/msgcookie.c Tue Jan 13 05:44:37 2004 +0000 @@ -183,7 +183,7 @@ /* XXX: hokey-assed. needs fixed. */ switch(reqclass) { case AIM_CAPS_BUDDYICON: return AIM_COOKIETYPE_OFTICON; - case AIM_CAPS_VOICE: return AIM_COOKIETYPE_OFTVOICE; + case AIM_CAPS_TALK: return AIM_COOKIETYPE_OFTVOICE; case AIM_CAPS_DIRECTIM: return AIM_COOKIETYPE_OFTIMAGE; case AIM_CAPS_CHAT: return AIM_COOKIETYPE_CHAT; case AIM_CAPS_GETFILE: return AIM_COOKIETYPE_OFTGET; diff -r 56b74730715f -r 697221d5d0ff src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Tue Jan 13 03:02:59 2004 +0000 +++ b/src/protocols/oscar/oscar.c Tue Jan 13 05:44:37 2004 +0000 @@ -2383,7 +2383,7 @@ "unknown rendezvous status!\n"); } } else if (args->reqclass & AIM_CAPS_GETFILE) { - } else if (args->reqclass & AIM_CAPS_VOICE) { + } else if (args->reqclass & AIM_CAPS_TALK) { } else if (args->reqclass & AIM_CAPS_BUDDYICON) { gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), userinfo->sn, args->info.icon.icon, @@ -3077,7 +3077,7 @@ case AIM_CAPS_BUDDYICON: tmp = _("Buddy Icon"); break; - case AIM_CAPS_VOICE: + case AIM_CAPS_TALK: tmp = _("Voice"); break; case AIM_CAPS_DIRECTIM: @@ -3096,7 +3096,7 @@ case AIM_CAPS_GAMES2: tmp = _("Games"); break; - case AIM_CAPS_SAVESTOCKS: + case AIM_CAPS_ADDINS: tmp = _("Add-Ins"); break; case AIM_CAPS_SENDBUDDYLIST: @@ -3135,9 +3135,16 @@ case AIM_CAPS_VIDEO: tmp = _("Video Chat"); break; + /* Not actually sure about this one... WinAIM doesn't show anything */ case AIM_CAPS_ICHATAV: tmp = _("iChat AV"); break; + case AIM_CAPS_LIVEVIDEO: + tmp = _("Live Video"); + break; + case AIM_CAPS_CAMERA: + tmp = _("Camera"); + break; default: tmp = NULL; break; @@ -4650,6 +4657,16 @@ static void oscar_add_buddy(GaimConnection *gc, const char *name, GaimGroup *g) { OscarData *od = (OscarData *)gc->proto_data; + + if (!aim_snvalid(name)) { + gchar *buf; + buf = g_strdup_printf(_("Could not add the buddy %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers. The buddy will be removed from your buddy list."), name); + gaim_notify_error(gc, NULL, _("Unable To Add"), buf); + g_free(buf); + /* ABC - Remove from locate list! */ + return; + } + #ifdef NOSSI aim_add_buddy(od->sess, od->conn, name); #else @@ -4684,7 +4701,7 @@ #else if (od->sess->ssi.received_data) { while (buddies) { - oscar_add_buddy(gc, (const char *)buddies->data, NULL); + oscar_add_buddy(gc, buddies->data, NULL); buddies = buddies->next; } } @@ -4978,7 +4995,7 @@ } else { gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: adding buddy %s from local list to server list\n", buddy->name); - aim_ssi_addbuddy(sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); + oscar_add_buddy(gc, buddy->name, group); } } } diff -r 56b74730715f -r 697221d5d0ff src/protocols/oscar/tlv.c --- a/src/protocols/oscar/tlv.c Tue Jan 13 03:02:59 2004 +0000 +++ b/src/protocols/oscar/tlv.c Tue Jan 13 05:44:37 2004 +0000 @@ -464,7 +464,7 @@ * passed in should be a bitwise %OR of any of the %AIM_CAPS constants: * * %AIM_CAPS_BUDDYICON Supports Buddy Icons - * %AIM_CAPS_VOICE Supports Voice Chat + * %AIM_CAPS_TALK Supports Voice Chat * %AIM_CAPS_IMIMAGE Supports DirectIM/IMImage * %AIM_CAPS_CHAT Supports Chat * %AIM_CAPS_GETFILE Supports Get File functions diff -r 56b74730715f -r 697221d5d0ff src/protocols/oscar/util.c --- a/src/protocols/oscar/util.c Tue Jan 13 03:02:59 2004 +0000 +++ b/src/protocols/oscar/util.c Tue Jan 13 05:44:37 2004 +0000 @@ -157,6 +157,37 @@ return 0; } +/** + * Check if the given screen name is a valid AIM or ICQ screen name. + * + * @return 1 if the screen name is valid, 0 if not. + */ +faim_export int aim_snvalid(const char *sn) +{ + int isICQ = 0; + int i = 0; + + if (!sn) + return 0; + + if (isdigit(sn[0])) + isICQ = 1; + + while (sn[i] != '\0') { + /* If it started with a digit then it betta be all digits, ho */ + if (isICQ) { + if (!isdigit(sn[i])) + return 0; + } else { + if (!isalnum(sn[i]) && (sn[i] != ' ')) + return 0; + } + i++; + } + + return 1; +} + /* * int snlen(const char *) *