Mercurial > pidgin
changeset 771:72e556f6b99d
[gaim-migrate @ 781]
libfaim gets warnings, and other minor changes
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 28 Aug 2000 05:07:43 +0000 |
parents | 172c5cf98dfa |
children | bddbc51abc43 |
files | libfaim/CHANGES libfaim/CHANGES.gaim libfaim/README.gaim libfaim/aim_chatnav.c libfaim/aim_login.c libfaim/aim_misc.c libfaim/aim_rxhandlers.c libfaim/aim_snac.c libfaim/aim_tlv.c libfaim/faim/aim.h src/oscar.c src/server.c |
diffstat | 12 files changed, 173 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/libfaim/CHANGES Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/CHANGES Mon Aug 28 05:07:43 2000 +0000 @@ -1,6 +1,11 @@ No release numbers ------------------ + - Mon Aug 28 03:11:15 GMT 2000 + - Adds lots of comments + - Add AIM_CLASS_ALLUSERS constant for setgrouppermmask() + - Add warnings support (jbm) + - Mon Aug 21 22:00:18 UTC 2000 - Implement SNAC login MD5 (thanks to Sonuvbob for that one) - Clear out all that old login cruft. Much cleaner now.
--- a/libfaim/CHANGES.gaim Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/CHANGES.gaim Mon Aug 28 05:07:43 2000 +0000 @@ -1,3 +1,6 @@ + +Mon Aug 28 05:02:39 UTC 2000 EWarmenhoven + - libfaim gets warnings. no blocking, just warnings. Tue Aug 22 23:34:47 UTC 2000 EWarmenhoven - New login method. Don't ask me anything about it. The only
--- a/libfaim/README.gaim Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/README.gaim Mon Aug 28 05:07:43 2000 +0000 @@ -14,6 +14,8 @@ So far the changes to libfaim that I've made are: - remove mkbuildinfo.sh and put the #defines it creates into Makefile.am - add #if HAVE_GETADDRINFO in aim_ft.c for Solaris people +- aim_tlv.c: deleted a printf +- aim_snac.c: in aim_remsnac, default cur to NULL, to avoid segfault And finally, a word of warning. Gaim/Faim is VERY buggy. Please, don't use this for anything other than laughs right now. Hopefully we'll get it working better @@ -41,6 +43,7 @@ Setting your info Getting users' info Getting users' away messages +Warning users/getting warned Chat: - joining rooms - leaving rooms @@ -53,7 +56,6 @@ CURRENTLY UNSUPPORTED FEATURES ============================== Telling the server who's on your permit/deny lists -Warning users/getting warned Chat: - whispering (this will never happen) - creating rooms (needed to join empty rooms) @@ -79,7 +81,9 @@ - What *is* protocol-dependent about the RVOUS stuff is that only Oscar can request RVOUS actions, though both can receive them. -- Warnings and Dir Info are not in libfaim yet, and so are not in Gaim/Faim yet. +- Dir Info is not in libfaim yet, and so is not in Gaim/Faim yet. + +- Warnings are there now. Yes, I know it says the wrong value. - There are also FIXME's scattered about gaim. Grep around for those, figure out what needs to be fixed, do that sort of thing. :) (Fixing the things listed
--- a/libfaim/aim_chatnav.c Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/aim_chatnav.c Mon Aug 28 05:07:43 2000 +0000 @@ -141,6 +141,19 @@ if (aim_gettlv(innerlist, 0x0004, 1)) ; + /* + * Type 0x0002: Unknown + */ + if (aim_gettlv(innerlist, 0x0002, 1)) { + struct aim_tlv_t *tmptlv; + unsigned short classperms = 0; + + tmptlv = aim_gettlv(innerlist, 0x0002, 1); + classperms = aimutil_get16(tmptlv->value); + + printf("faim: class permissions %x\n", classperms); + } + /* * Type 0x00c9: Unknown */ @@ -154,7 +167,7 @@ ; /* - * Type 0x00d0: Unknown + * Type 0x00d0: Mandatory Channels? */ if (aim_gettlv(innerlist, 0x00d0, 1)) ; @@ -166,7 +179,7 @@ ; /* - * Type 0x00d2: Unknown + * Type 0x00d2: Maximum Occupancy? */ if (aim_gettlv(innerlist, 0x00d2, 1)) ; @@ -180,10 +193,22 @@ exchanges[curexchange-1].name = NULL; /* - * Type 0x00d5: Unknown + * Type 0x00d5: Creation Permissions + * + * 0 Creation not allowed + * 1 Room creation allowed + * 2 Exchange creation allowed + * */ - if (aim_gettlv(innerlist, 0x00d5, 1)) - ; + if (aim_gettlv(innerlist, 0x00d5, 1)) { + struct aim_tlv_t *tmptlv; + unsigned char createperms = 0; + + tmptlv = aim_gettlv(innerlist, 0x00d5, 1); + createperms = aimutil_get8(tmptlv->value); + + printf("faim: creation permissions %x\n", createperms); + } /* * Type 0x00d6: Character Set (First Time)
--- a/libfaim/aim_login.c Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/aim_login.c Mon Aug 28 05:07:43 2000 +0000 @@ -306,7 +306,8 @@ rxcallback_t userfunc; keylen = aimutil_get16(command->data+10); - key = malloc(keylen+1); + if (!(key = malloc(keylen+1))) + return ret; memcpy(key, command->data+12, keylen); key[keylen] = '\0';
--- a/libfaim/aim_misc.c Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/aim_misc.c Mon Aug 28 05:07:43 2000 +0000 @@ -250,7 +250,11 @@ /* * aim_bos_setgroupperm(mask) * - * Set group permisson mask. Normally 0x1f. + * Set group permisson mask. Normally 0x1f (all classes). + * + * The group permission mask allows you to keep users of a certain + * class or classes from talking to you. The mask should be + * a bitwise OR of all the user classes you want to see you. * */ u_long aim_bos_setgroupperm(struct aim_session_t *sess, @@ -336,12 +340,8 @@ } /* - * send_login_phase3(int socket) - * * Request Rate Information. * - * TODO: Move to aim_conn. - * TODO: Move to SNAC interface. */ u_long aim_bos_reqrate(struct aim_session_t *sess, struct aim_conn_t *conn) @@ -350,8 +350,6 @@ } /* - * send_login_phase3b(int socket) - * * Rate Information Response Acknowledge. * */ @@ -389,7 +387,7 @@ * Sets privacy flags. Normally 0x03. * * Bit 1: Allows other AIM users to see how long you've been idle. - * + * Bit 2: Allows other AIM users to see how long you've been a member. * */ u_long aim_bos_setprivacyflags(struct aim_session_t *sess, @@ -503,10 +501,7 @@ * aim_bos_nop() * * No-op. WinAIM sends these every 4min or so to keep - * the connection alive. With the recent changes - * in the OSCAR servers, it looks like we must do the - * same or be disconnected with a mysterious 'you logged - * on from another client' message. + * the connection alive. Its not real necessary. * */ u_long aim_bos_nop(struct aim_session_t *sess, @@ -540,6 +535,46 @@ } /* + * aim_send_warning(struct aim_session_t *sess, + * struct aim_conn_t *conn, char *destsn, int anon) + * send a warning to destsn. + * anon is anonymous or not; + * AIM_WARN_ANON anonymous + * + * returns -1 on error (couldn't alloc packet), next snacid on success. + * + */ +int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon) +{ + struct command_tx_struct *newpacket; + int curbyte; + + if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, strlen(destsn)+13))) + return -1; + + newpacket->lock = 1; + + curbyte = 0; + curbyte += aim_putsnac(newpacket->data+curbyte, + 0x0004, 0x0008, 0x0000, sess->snac_nextid); + + curbyte += aimutil_put16(newpacket->data+curbyte, (anon & AIM_WARN_ANON)?1:0); + + curbyte += aimutil_put8(newpacket->data+curbyte, strlen(destsn)); + + curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn)); + + newpacket->commandlen = curbyte; + newpacket->lock = 0; + + aim_tx_enqueue(sess, newpacket); + + return (sess->snac_nextid++); +} + + + +/* * aim_debugconn_sendconnect() * * For aimdebugd. If you don't know what it is, you don't want to.
--- a/libfaim/aim_rxhandlers.c Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/aim_rxhandlers.c Mon Aug 28 05:07:43 2000 +0000 @@ -421,6 +421,9 @@ case 0x000f: workingPtr->handled = aim_callhandler_noparam(sess, workingPtr->conn, 0x0001, 0x000f, workingPtr); break; + case 0x0010: + workingPtr->handled = aim_parse_evilnotify_middle(sess, workingPtr); + break; case 0x0013: workingPtr->handled = aim_parsemotd_middle(sess, workingPtr); break; @@ -651,6 +654,31 @@ return ret; } +int aim_parse_evilnotify_middle(struct aim_session_t *sess, struct command_rx_struct *command) +{ + rxcallback_t userfunc = NULL; + int ret = 1, pos; + char *sn = NULL; + + if(command->commandlen < 12) /* a warning level dec sends this */ + return 1; + + if ((pos = aimutil_get8(command->data+ 12)) > MAXSNLEN) + return 1; + + if(!(sn = (char *)calloc(1, pos+1))) + return 1; + + memcpy(sn, command->data+13, pos); + + if ((userfunc = aim_callhandler(command->conn, 0x0001, 0x0010))) + ret = userfunc(sess, command, sn); + + free(sn); + + return ret; +} + int aim_parsemotd_middle(struct aim_session_t *sess, struct command_rx_struct *command, ...) { @@ -661,7 +689,14 @@ u_short id; /* - * Dunno. + * Code. + * + * Valid values: + * 1 Mandatory upgrade + * 2 Advisory upgrade + * 3 System bulletin + * 4 Nothing's wrong ("top o the world" -- normal) + * */ id = aimutil_get16(command->data+10);
--- a/libfaim/aim_snac.c Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/aim_snac.c Mon Aug 28 05:07:43 2000 +0000 @@ -43,8 +43,7 @@ if (!newsnac) return 0; - snac = calloc(1, sizeof(struct aim_snac_t)); - if (!snac) + if (!(snac = calloc(1, sizeof(struct aim_snac_t)))) return 0; memcpy(snac, newsnac, sizeof(struct aim_snac_t)); snac->issuetime = time(&snac->issuetime); @@ -53,12 +52,8 @@ index = snac->id % FAIM_SNAC_HASH_SIZE; faim_mutex_lock(&sess->snac_hash_locks[index]); - if (!sess->snac_hash[index]) - sess->snac_hash[index] = snac; - else { - snac->next = sess->snac_hash[index]; - sess->snac_hash[index] = snac; - } + snac->next = sess->snac_hash[index]; + sess->snac_hash[index] = snac; faim_mutex_unlock(&sess->snac_hash_locks[index]); return(snac->id); @@ -74,7 +69,7 @@ struct aim_snac_t *aim_remsnac(struct aim_session_t *sess, u_long id) { - struct aim_snac_t *cur; + struct aim_snac_t *cur = NULL; int index; index = id % FAIM_SNAC_HASH_SIZE;
--- a/libfaim/aim_tlv.c Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/aim_tlv.c Mon Aug 28 05:07:43 2000 +0000 @@ -48,7 +48,7 @@ cur->tlv->length = length; cur->tlv->value = (u_char *)malloc(length*sizeof(u_char)); memcpy(cur->tlv->value, buf+pos, length); - + cur->next = list; list = cur; }
--- a/libfaim/faim/aim.h Fri Aug 25 22:09:34 2000 +0000 +++ b/libfaim/faim/aim.h Mon Aug 28 05:07:43 2000 +0000 @@ -94,6 +94,8 @@ * for WinAIM clients (up through the latest (4.0.1957)) to * send any more than 1kb. Amaze all your windows friends * with utterly oversized instant messages! + * + * XXX: the real limit is the total SNAC size at 8192. Fix this. * */ #define MAXMSGLEN 7987 @@ -331,15 +333,17 @@ u_short capabilities; }; -#define AIM_CLASS_TRIAL 0x0001 -#define AIM_CLASS_UNKNOWN2 0x0002 +#define AIM_CLASS_TRIAL 0x0001 /* "damned transients" */ +#define AIM_CLASS_ADMINISTRATOR 0x0002 #define AIM_CLASS_AOL 0x0004 -#define AIM_CLASS_UNKNOWN4 0x0008 +#define AIM_CLASS_OSCAR_PAY 0x0008 #define AIM_CLASS_FREE 0x0010 #define AIM_CLASS_AWAY 0x0020 #define AIM_CLASS_UNKNOWN40 0x0040 #define AIM_CLASS_UNKNOWN80 0x0080 +#define AIM_CLASS_ALLUSERS 0x001f + /* * TLV handling */ @@ -484,6 +488,12 @@ #define AIM_VISIBILITYCHANGE_DENYADD 0x07 #define AIM_VISIBILITYCHANGE_DENYREMOVE 0x08 +#define AIM_PRIVFLAGS_ALLOWIDLE 0x01 +#define AIM_PRIVFLAGS_ALLOWMEMBERSINCE 0x02 + +#define AIM_WARN_ANON 0x01 + +int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon); u_long aim_bos_nop(struct aim_session_t *, struct aim_conn_t *); u_long aim_bos_setidle(struct aim_session_t *, struct aim_conn_t *, u_long); u_long aim_bos_changevisibility(struct aim_session_t *, struct aim_conn_t *, int, char *); @@ -514,6 +524,7 @@ int aim_parse_generalerrs(struct aim_session_t *, struct command_rx_struct *command, ...); int aim_parsemotd_middle(struct aim_session_t *sess, struct command_rx_struct *command, ...); int aim_parse_ratechange_middle(struct aim_session_t *sess, struct command_rx_struct *command); +int aim_parse_evilnotify_middle(struct aim_session_t *sess, struct command_rx_struct *command); int aim_parse_msgack_middle(struct aim_session_t *sess, struct command_rx_struct *command); /* aim_im.c */
--- a/src/oscar.c Fri Aug 25 22:09:34 2000 +0000 +++ b/src/oscar.c Mon Aug 28 05:07:43 2000 +0000 @@ -87,6 +87,7 @@ static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); static int gaim_parse_msgack (struct aim_session_t *, struct command_rx_struct *, ...); static int gaim_parse_ratechange (struct aim_session_t *, struct command_rx_struct *, ...); +static int gaim_parse_evilnotify (struct aim_session_t *, struct command_rx_struct *, ...); static int gaim_directim_incoming(struct aim_session_t *, struct command_rx_struct *, ...); static int gaim_directim_typing (struct aim_session_t *, struct command_rx_struct *, ...); @@ -308,6 +309,7 @@ aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_misses, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); + aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_misses, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_user_info, 0); aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); @@ -345,9 +347,9 @@ case AIM_CONN_TYPE_BOS: aim_bos_reqrate(sess, command->conn); aim_bos_ackrateresp(sess, command->conn); - aim_bos_setprivacyflags(sess, command->conn, 0x00000003); + aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS); - aim_bos_setgroupperm(sess, command->conn, 0x1f); + aim_bos_setgroupperm(sess, command->conn, AIM_CLASS_ALLUSERS); debug_print("done with BOS ServerReady\n"); break; case AIM_CONN_TYPE_CHATNAV: @@ -512,6 +514,8 @@ if (info->class & AIM_CLASS_TRIAL) type |= UC_UNCONFIRMED; + else if (info->class & AIM_CLASS_ADMINISTRATOR) + type |= UC_ADMIN; else if (info->class & AIM_CLASS_AOL) type |= UC_AOL; else if (info->class & AIM_CLASS_FREE) @@ -787,11 +791,14 @@ msg = va_arg(ap, char *); va_end(ap); - sprintf(debug_buff, "MOTD: %s\n", msg); + sprintf(debug_buff, "MOTD: %s (%d)\n", msg, id); debug_print(debug_buff); sprintf(debug_buff, "Gaim %s / Libfaim %s\n", VERSION, aim_getbuildstring()); debug_print(debug_buff); + if (id != 4) + do_error_dialog(_("Your connection may be lost."), + _("AOL error")); return 1; } @@ -970,6 +977,19 @@ return 1; }; +int gaim_parse_evilnotify(struct aim_session_t *sess, struct command_rx_struct *command, ...) { + va_list ap; + char *sn; + + va_start(ap, command); + sn = va_arg(ap, char *); + va_end(ap); + + serv_got_eviled(sn, 0); + + return 1; +} + int gaim_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...) { va_list ap; char *sn = NULL, *msg = NULL;