From: Sean E. <sea...@us...> - 2002-05-05 18:42:15
|
Update of /cvsroot/gaim/gaim/src/protocols/oscar In directory usw-pr-cvs1:/tmp/cvs-serv18131/src/protocols/oscar Modified Files: aim.h oscar.c ssi.c Log Message: Among other things, a warning for when your OSCAR buddy list is too long. Thanks KingAnt Index: aim.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/oscar/aim.h,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- aim.h 12 Apr 2002 02:43:50 -0000 1.39 +++ aim.h 5 May 2002 18:42:10 -0000 1.40 @@ -1037,10 +1037,11 @@ faim_export int aim_ssi_modend(aim_session_t *sess, aim_conn_t *conn); /* These handle the local variables */ -faim_export int aim_ssi_inlist(aim_session_t *sess, aim_conn_t *conn, char *name, fu16_t type); -faim_export char *aim_ssi_getparentgroup(aim_session_t *sess, aim_conn_t *conn, char *name); -faim_export int aim_ssi_getpermdeny(aim_session_t *sess, aim_conn_t *conn); -faim_export fu32_t aim_ssi_getpresence(aim_session_t *sess, aim_conn_t *conn); +faim_export struct aim_ssi_item *aim_ssi_itemlist_find(struct aim_ssi_item *list, fu16_t gid, fu16_t bid); +faim_export struct aim_ssi_item *aim_ssi_itemlist_finditem(struct aim_ssi_item *list, char *gn, char *sn, fu16_t type); +faim_export struct aim_ssi_item *aim_ssi_itemlist_findparent(struct aim_ssi_item *list, char *sn); +faim_export int aim_ssi_getpermdeny(struct aim_ssi_item *list); +faim_export fu32_t aim_ssi_getpresence(struct aim_ssi_item *list); faim_export int aim_ssi_cleanlist(aim_session_t *sess, aim_conn_t *conn); faim_export int aim_ssi_addbuddies(aim_session_t *sess, aim_conn_t *conn, char *gn, char **sn, unsigned int num); faim_export int aim_ssi_addmastergroup(aim_session_t *sess, aim_conn_t *conn); @@ -1052,7 +1053,7 @@ faim_export int aim_ssi_delgroups(aim_session_t *sess, aim_conn_t *conn, char **gn, unsigned int num); faim_export int aim_ssi_deletelist(aim_session_t *sess, aim_conn_t *conn); faim_export int aim_ssi_delpord(aim_session_t *sess, aim_conn_t *conn, char **sn, unsigned int num, fu16_t type); -faim_export int aim_ssi_setpermdeny(aim_session_t *sess, aim_conn_t *conn, int permdeny); +faim_export int aim_ssi_setpermdeny(aim_session_t *sess, aim_conn_t *conn, fu8_t permdeny, fu32_t vismask); faim_export int aim_ssi_setpresence(aim_session_t *sess, aim_conn_t *conn, fu32_t presence); struct aim_icq_offlinemsg { Index: oscar.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/oscar/oscar.c,v retrieving revision 1.134 retrieving revision 1.135 diff -u -d -r1.134 -r1.135 --- oscar.c 26 Apr 2002 22:32:37 -0000 1.134 +++ oscar.c 5 May 2002 18:42:10 -0000 1.135 @@ -2785,7 +2785,7 @@ if (odata->icq) { aim_add_buddy(odata->sess, odata->conn, name); } else { - if ((odata->sess->ssi.received_data) && !(aim_ssi_inlist(odata->sess, odata->conn, name, 0x0000))) { + if ((odata->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, name, 0x0000))) { debug_printf("ssi: adding buddy %s to group %s\n", name, find_group_by_buddy(g, name)->name); aim_ssi_addbuddies(odata->sess, odata->conn, find_group_by_buddy(g, name)->name, &name, 1); } @@ -2813,13 +2813,13 @@ for (curgrp=g->groups; curgrp; curgrp=g_slist_next(curgrp)) { tmp = 0; for (curbud=((struct group*)curgrp->data)->members; curbud; curbud=curbud->next) - if (!aim_ssi_inlist(odata->sess, odata->conn, ((struct buddy*)curbud->data)->name, 0x0000)) + if (!aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, ((struct buddy*)curbud->data)->name, 0x0000)) tmp++; if (tmp) { char **sns = (char **)malloc(tmp*sizeof(char*)); tmp = 0; for (curbud=((struct group*)curgrp->data)->members; curbud; curbud=curbud->next) - if (!aim_ssi_inlist(odata->sess, odata->conn, ((struct buddy*)curbud->data)->name, 0x0000)) { + if (!aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, ((struct buddy*)curbud->data)->name, 0x0000)) { debug_printf("ssi: adding buddy %s to group %s\n", ((struct buddy*)curbud->data)->name, ((struct group*)curgrp->data)->name); sns[tmp] = (char *)((struct buddy*)curbud->data)->name; tmp++; @@ -2847,8 +2847,8 @@ aim_remove_buddy(odata->sess, odata->conn, name); } else { if (odata->sess->ssi.received_data) { - char *ssigroup; - while (aim_ssi_inlist(odata->sess, odata->conn, name, 0x0000) && (ssigroup = aim_ssi_getparentgroup(odata->sess, odata->conn, name)) && !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup, &name, 1)) + struct aim_ssi_item *ssigroup; + while (aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, name, 0x0000) && (ssigroup = aim_ssi_itemlist_findparent(odata->sess->ssi.items, name)) && !aim_ssi_delbuddies(odata->sess, odata->conn, ssigroup->name, &name, 1)) debug_printf("ssi: deleted buddy %s from group %s\n", name, group); } } @@ -2865,14 +2865,14 @@ GList *cur; int tmp = 0; for (cur=buddies; cur; cur=cur->next) - if (aim_ssi_inlist(odata->sess, odata->conn, cur->data, 0x0000)) + if (aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, cur->data, 0x0000)) tmp++; if (tmp) { char **sns; sns = (char **)malloc(tmp*sizeof(char*)); tmp = 0; for (cur=buddies; cur; cur=cur->next) - if (aim_ssi_inlist(odata->sess, odata->conn, cur->data, 0x0000)) { + if (aim_ssi_itemlist_finditem(odata->sess->ssi.items, NULL, cur->data, 0x0000)) { debug_printf("ssi: deleting buddy %s from group %s\n", cur->data, group); sns[tmp] = cur->data; tmp++; @@ -2919,7 +2919,7 @@ aim_ssi_enable(sess, fr->conn); /* Clean the buddy list */ - /* aim_ssi_cleanlist(sess, fr->conn); */ + aim_ssi_cleanlist(sess, fr->conn); /* Add from server list to local list */ tmp = 0; @@ -2972,7 +2972,7 @@ case 0x0004: /* Permit/deny setting */ if (curitem->data) { fu8_t permdeny; - if ((permdeny = aim_ssi_getpermdeny(sess, fr->conn)) && (permdeny != gc->permdeny)) { + if ((permdeny = aim_ssi_getpermdeny(sess->ssi.items)) && (permdeny != gc->permdeny)) { debug_printf("ssi: changing permdeny from %d to %d\n", gc->permdeny, permdeny); gc->permdeny = permdeny; tmp++; @@ -2998,13 +2998,13 @@ GSList *curbud; tmp = 0; for (curbud=((struct group*)cur->data)->members; curbud; curbud=curbud->next) - if (!aim_ssi_inlist(sess, fr->conn, ((struct buddy*)curbud->data)->name, 0x0000)) + if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, ((struct buddy*)curbud->data)->name, 0x0000)) tmp++; if (tmp) { sns = (char **)malloc(tmp*sizeof(char*)); tmp = 0; for (curbud=((struct group*)cur->data)->members; curbud; curbud=curbud->next) - if (!aim_ssi_inlist(sess, fr->conn, ((struct buddy*)curbud->data)->name, 0x0000)) { + if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, ((struct buddy*)curbud->data)->name, 0x0000)) { debug_printf("ssi: adding buddy %s from local list to server list\n", ((struct buddy*)curbud->data)->name); sns[tmp] = ((char *)((struct buddy*)curbud->data)->name); tmp++; @@ -3019,13 +3019,13 @@ if (gc->permit) { tmp = 0; for (cur=gc->permit; cur; cur=cur->next) - if (!aim_ssi_inlist(sess, fr->conn, cur->data, 0x0002)) + if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, cur->data, 0x0002)) tmp++; if (tmp) { sns = (char **)malloc(tmp*sizeof(char*)); tmp = 0; for (cur=gc->permit; cur; cur=cur->next) - if (!aim_ssi_inlist(sess, fr->conn, cur->data, 0x0002)) { + if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, cur->data, 0x0002)) { debug_printf("ssi: adding permit %s from local list to server list\n", cur->data); sns[tmp] = cur->data; tmp++; @@ -3039,13 +3039,13 @@ if (gc->deny) { tmp = 0; for (cur=gc->deny; cur; cur=cur->next) - if (!aim_ssi_inlist(sess, fr->conn, cur->data, 0x0003)) + if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, cur->data, 0x0003)) tmp++; if (tmp) { sns = (char **)malloc(tmp*sizeof(char*)); tmp = 0; for (cur=gc->deny; cur; cur=cur->next) - if (!aim_ssi_inlist(sess, fr->conn, cur->data, 0x0003)) { + if (!aim_ssi_itemlist_finditem(sess->ssi.items, NULL, cur->data, 0x0003)) { debug_printf("ssi: adding deny %s from local list to server list\n", cur->data); sns[tmp] = cur->data; tmp++; @@ -3056,10 +3056,23 @@ } /* Presence settings (idle time visibility) */ - if ((tmp = aim_ssi_getpresence(sess, fr->conn)) != 0xFFFFFFFF) + if ((tmp = aim_ssi_getpresence(sess->ssi.items)) != 0xFFFFFFFF) if (report_idle && !(tmp & 0x400)) aim_ssi_setpresence(sess, fr->conn, tmp | 0x400); - } + + /* Check for maximum number of buddies */ + for (cur=gc->groups, tmp=0; cur; cur=g_slist_next(cur)) { + tmp = tmp + g_slist_length(cur->data->members); + + if (tmp > odata->rights.maxbuddies) { + char *dialog_msg = g_strdup_printf(_("The maximum number of buddies allowed in your buddy list is %d, and you have %d." + " Until you are below the limit, some buddies will not show up as online."), + odata->rights.maxbuddies, tmp); + do_error_dialog(dialog_msg, _("Gaim - Warning")); + g_free(dialog_msg); + } + + } /* end if (gc) */ return 1; } @@ -3520,7 +3533,7 @@ signoff_blocked(gc); } else { if (od->sess->ssi.received_data) - aim_ssi_setpermdeny(od->sess, od->conn, gc->permdeny); + aim_ssi_setpermdeny(od->sess, od->conn, gc->permdeny, 0xffffffff); } } Index: ssi.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/oscar/ssi.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ssi.c 12 Apr 2002 02:40:41 -0000 1.8 +++ ssi.c 5 May 2002 18:42:11 -0000 1.9 @@ -5,6 +5,15 @@ * such as a users buddy list, permit/deny list, and permit/deny preferences, * to be stored on the server, so that they can be accessed from any client. * + * We keep a copy of the ssi data in sess->ssi, because the data needs to be + * accessed for various reasons. So all the "aim_ssi_itemlist_bleh" functions + * near the top just manage the local data. + * + * The SNAC sending and receiving functions are lower down in the file, and + * they're simpler. They are in the order of the subtypes they deal with, + * starting with the request rights function (subtype 0x0002), then parse + * rights (subtype 0x0003), then--well, you get the idea. [...1238 lines suppressed...] - - /* Send the add item SNAC */ aim_ssi_addmoddel(sess, conn, &cur, 1, AIM_CB_SSI_ADD); } @@ -1074,6 +1182,14 @@ fu8_t fmtver; /* guess */ fu16_t revision; fu32_t timestamp; + + /* When you set the version for the SSI family to 2-4, the beginning of this changes. + * Instead of the version and then the revision, there is "0x0006" and then a type + * 0x0001 TLV containing the 2 byte SSI family version that you sent earlier. Also, + * the SNAC flags go from 0x0000 to 0x8000. I guess the 0x0006 is the length of the + * TLV(s) that follow. The rights SNAC does the same thing, with the differing flag + * and everything. + */ fmtver = aimbs_get8(bs); /* Version of ssi data. Should be 0x00 */ revision = aimbs_get16(bs); /* # of times ssi data has been modified */ |