comparison src/protocols/oscar/ssi.c @ 4236:9641bd9c79f5

[gaim-migrate @ 4482] Hi there. Me again. A small patch from Mr. Reisner that makes the rename buddy dialog and jabber's vcard dialog (set jabber info) dialog buttons follow the gnome HIG. Thank you thank you. Pizza pizza. Changes to oscar.c... Make some debug_printf's not i18nish. 1) They don't really help us if they're in another language. 2) Translators have enough strings as it is I made a few more of the ICQ auth dialogs show ##### (alias) instead of just #####. Change how some data in ssi.c is allocated/freed. It's a cleaner implementation this way, but maybe just a little slower. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 08 Jan 2003 01:37:11 +0000
parents cba92ec56248
children 0e4be672f516
comparison
equal deleted inserted replaced
4235:cba92ec56248 4236:9641bd9c79f5
145 145
146 /* Set the type */ 146 /* Set the type */
147 new->type = type; 147 new->type = type;
148 148
149 /* Set the TLV list */ 149 /* Set the TLV list */
150 new->data = data; 150 new->data = aim_tlvlist_copy(data);
151 151
152 /* Add the item to the list in the correct numerical position. Fancy, eh? */ 152 /* Add the item to the list in the correct numerical position. Fancy, eh? */
153 if (*list) { 153 if (*list) {
154 if ((new->gid < (*list)->gid) || ((new->gid == (*list)->gid) && (new->bid < (*list)->bid))) { 154 if ((new->gid < (*list)->gid) || ((new->gid == (*list)->gid) && (new->bid < (*list)->bid))) {
155 new->next = *list; 155 new->next = *list;
691 if (comment) 691 if (comment)
692 aim_addtlvtochain_raw(&data, 0x013c, strlen(comment), comment); 692 aim_addtlvtochain_raw(&data, 0x013c, strlen(comment), comment);
693 693
694 /* Add that bad boy */ 694 /* Add that bad boy */
695 aim_ssi_itemlist_add(&sess->ssi.local, name, parent->gid, 0xFFFF, AIM_SSI_TYPE_BUDDY, data); 695 aim_ssi_itemlist_add(&sess->ssi.local, name, parent->gid, 0xFFFF, AIM_SSI_TYPE_BUDDY, data);
696 aim_freetlvchain(&data);
696 697
697 /* Modify the parent group */ 698 /* Modify the parent group */
698 aim_ssi_itemlist_rebuildgroup(sess->ssi.local, group); 699 aim_ssi_itemlist_rebuildgroup(sess->ssi.local, group);
699 700
700 /* Sync our local list with the server list */ 701 /* Sync our local list with the server list */
927 if ((tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, NULL, AIM_SSI_TYPE_PDINFO))) { 928 if ((tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, NULL, AIM_SSI_TYPE_PDINFO))) {
928 aim_freetlvchain(&tmp->data); 929 aim_freetlvchain(&tmp->data);
929 tmp->data = data; 930 tmp->data = data;
930 } else { 931 } else {
931 tmp = aim_ssi_itemlist_add(&sess->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PDINFO, data); 932 tmp = aim_ssi_itemlist_add(&sess->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PDINFO, data);
933 aim_freetlvchain(&data);
932 } 934 }
933 935
934 /* Sync our local list with the server list */ 936 /* Sync our local list with the server list */
935 aim_ssi_sync(sess, conn); 937 aim_ssi_sync(sess, conn);
936 938
959 if ((tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, NULL, AIM_SSI_TYPE_PRESENCEPREFS))) { 961 if ((tmp = aim_ssi_itemlist_finditem(sess->ssi.local, NULL, NULL, AIM_SSI_TYPE_PRESENCEPREFS))) {
960 aim_freetlvchain(&tmp->data); 962 aim_freetlvchain(&tmp->data);
961 tmp->data = data; 963 tmp->data = data;
962 } else { 964 } else {
963 tmp = aim_ssi_itemlist_add(&sess->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PRESENCEPREFS, data); 965 tmp = aim_ssi_itemlist_add(&sess->ssi.local, NULL, 0x0000, 0xFFFF, AIM_SSI_TYPE_PRESENCEPREFS, data);
966 aim_freetlvchain(&data);
964 } 967 }
965 968
966 /* Sync our local list with the server list */ 969 /* Sync our local list with the server list */
967 aim_ssi_sync(sess, conn); 970 aim_ssi_sync(sess, conn);
968 971
1066 */ 1069 */
1067 static int parsedata(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) 1070 static int parsedata(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
1068 { 1071 {
1069 int ret = 0; 1072 int ret = 0;
1070 aim_rxcallback_t userfunc; 1073 aim_rxcallback_t userfunc;
1071 struct aim_ssi_item *cur, *new;
1072 fu8_t fmtver; /* guess */ 1074 fu8_t fmtver; /* guess */
1073 fu16_t numitems, namelen; 1075 fu16_t numitems, namelen, gid, bid, type;
1074 fu32_t timestamp; 1076 fu32_t timestamp;
1077 char *name;
1078 aim_tlvlist_t *data;
1075 1079
1076 if (snac->flags & 0x0001) { 1080 if (snac->flags & 0x0001) {
1077 /* XXX - Free all ssi data? */ 1081 /* XXX - Free all ssi data? */
1078 } 1082 }
1079 1083
1080 fmtver = aimbs_get8(bs); /* Version of ssi data. Should be 0x00 */ 1084 fmtver = aimbs_get8(bs); /* Version of ssi data. Should be 0x00 */
1081 numitems = aimbs_get16(bs); /* # of times ssi data has been modified */ 1085 numitems = aimbs_get16(bs); /* # of items in this SSI SNAC */
1082 sess->ssi.numitems += numitems; 1086 sess->ssi.numitems += numitems;
1083 1087
1084 /* Read in the list */ 1088 /* Read in the list */
1085 /* If we already have a partial list, move cur to the end of it */
1086 if (sess->ssi.official)
1087 for (cur=sess->ssi.official; cur->next; cur=cur->next);
1088 while (aim_bstream_empty(bs) > 4) { /* last four bytes are timestamp */ 1089 while (aim_bstream_empty(bs) > 4) { /* last four bytes are timestamp */
1089 if (!sess->ssi.official) {
1090 if (!(sess->ssi.official = malloc(sizeof(struct aim_ssi_item))))
1091 return -ENOMEM;
1092 cur = sess->ssi.official;
1093 } else {
1094 if (!(cur->next = malloc(sizeof(struct aim_ssi_item))))
1095 return -ENOMEM;
1096 cur = cur->next;
1097 }
1098 if ((namelen = aimbs_get16(bs))) 1090 if ((namelen = aimbs_get16(bs)))
1099 cur->name = aimbs_getstr(bs, namelen); 1091 name = aimbs_getstr(bs, namelen);
1100 else 1092 else
1101 cur->name = NULL; 1093 name = NULL;
1102 cur->gid = aimbs_get16(bs); 1094 gid = aimbs_get16(bs);
1103 cur->bid = aimbs_get16(bs); 1095 bid = aimbs_get16(bs);
1104 cur->type = aimbs_get16(bs); 1096 type = aimbs_get16(bs);
1105 cur->data = aim_readtlvchain_len(bs, aimbs_get16(bs)); 1097 data = aim_readtlvchain_len(bs, aimbs_get16(bs));
1106 cur->next = NULL; 1098 aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, data);
1099 free(name);
1100 aim_freetlvchain(&data);
1107 } 1101 }
1108 1102
1109 /* Read in the timestamp */ 1103 /* Read in the timestamp */
1110 timestamp = aimbs_get32(bs); 1104 timestamp = aimbs_get32(bs);
1111 sess->ssi.timestamp = timestamp; 1105 sess->ssi.timestamp = timestamp;
1112 1106
1113 if (!(snac->flags & 0x0001)) { 1107 if (!(snac->flags & 0x0001)) {
1114 /* Make a copy of the list */ 1108 /* Make a copy of the list */
1115 for (cur=sess->ssi.official; cur; cur=cur->next) { 1109 struct aim_ssi_item *cur;
1116 if (!sess->ssi.local) { 1110 for (cur=sess->ssi.official; cur; cur=cur->next)
1117 if (!(sess->ssi.local = malloc(sizeof(struct aim_ssi_item)))) 1111 aim_ssi_itemlist_add(&sess->ssi.local, cur->name, cur->gid, cur->bid, cur->type, cur->data);
1118 return -ENOMEM;
1119 new = sess->ssi.local;
1120 } else {
1121 if (!(new->next = malloc(sizeof(struct aim_ssi_item))))
1122 return -ENOMEM;
1123 new = new->next;
1124 }
1125 if (cur->name) {
1126 new->name = (char *)malloc((strlen(cur->name)+1)*sizeof(char));
1127 strcpy(new->name, cur->name);
1128 } else
1129 new->name = NULL;
1130 new->gid = cur->gid;
1131 new->bid = cur->bid;
1132 new->type = cur->type;
1133 new->data = aim_tlvlist_copy(cur->data);
1134 new->next = NULL;
1135 }
1136 1112
1137 sess->ssi.received_data = 1; 1113 sess->ssi.received_data = 1;
1138 1114
1139 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 1115 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
1140 ret = userfunc(sess, rx, fmtver, sess->ssi.numitems, sess->ssi.official, sess->ssi.timestamp); 1116 ret = userfunc(sess, rx, fmtver, sess->ssi.numitems, sess->ssi.official, sess->ssi.timestamp);
1233 data = aim_readtlvchain_len(bs, len); 1209 data = aim_readtlvchain_len(bs, len);
1234 else 1210 else
1235 data = NULL; 1211 data = NULL;
1236 1212
1237 aim_ssi_itemlist_add(&sess->ssi.local, name, gid, bid, type, data); 1213 aim_ssi_itemlist_add(&sess->ssi.local, name, gid, bid, type, data);
1238 aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, aim_tlvlist_copy(data)); 1214 aim_ssi_itemlist_add(&sess->ssi.official, name, gid, bid, type, data);
1215 free(name);
1216 aim_freetlvchain(&data);
1239 1217
1240 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 1218 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
1241 ret = userfunc(sess, rx); 1219 ret = userfunc(sess, rx);
1242 1220
1243 free(name); 1221 free(name);
1299 } 1277 }
1300 1278
1301 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 1279 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
1302 ret = userfunc(sess, rx); 1280 ret = userfunc(sess, rx);
1303 1281
1282 free(name);
1304 aim_freetlvchain(&data); 1283 aim_freetlvchain(&data);
1305 free(name);
1306 } 1284 }
1307 1285
1308 return ret; 1286 return ret;
1309 } 1287 }
1310 1288
1366 for (cur=sess->ssi.pending; (cur && (cur->ack != 0xffff)); cur=cur->next) { 1344 for (cur=sess->ssi.pending; (cur && (cur->ack != 0xffff)); cur=cur->next) {
1367 if (cur->item) { 1345 if (cur->item) {
1368 if (cur->ack) { 1346 if (cur->ack) {
1369 /* Our action was unsuccessful, so change the local list back to how it was */ 1347 /* Our action was unsuccessful, so change the local list back to how it was */
1370 if (cur->action == AIM_CB_SSI_ADD) { 1348 if (cur->action == AIM_CB_SSI_ADD) {
1371 /* Remove the item from the items list */ 1349 /* Remove the item from the local list */
1372 if (cur->item->name) { 1350 if (cur->item->name) {
1373 cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char)); 1351 cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
1374 strcpy(cur->name, cur->item->name); 1352 strcpy(cur->name, cur->item->name);
1375 } 1353 }
1376 aim_ssi_itemlist_del(&sess->ssi.local, cur->item); 1354 aim_ssi_itemlist_del(&sess->ssi.local, cur->item);
1377 cur->item = NULL; 1355 cur->item = NULL;
1378 1356
1379 } else if (cur->action == AIM_CB_SSI_MOD) { 1357 } else if (cur->action == AIM_CB_SSI_MOD) {
1380 /* Replace the new item with the old item in the items list */ 1358 /* Replace the official item with the item in the local list */
1381 struct aim_ssi_item *cur1; 1359 struct aim_ssi_item *cur1;
1382 if ((cur1 = aim_ssi_itemlist_find(sess->ssi.local, cur->item->gid, cur->item->bid))) { 1360 if ((cur1 = aim_ssi_itemlist_find(sess->ssi.local, cur->item->gid, cur->item->bid))) {
1383 free(cur1->name); 1361 free(cur1->name);
1384 if (cur->item->name) { 1362 if (cur->item->name) {
1385 cur1->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char)); 1363 cur1->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
1389 aim_freetlvchain(&cur1->data); 1367 aim_freetlvchain(&cur1->data);
1390 cur1->data = aim_tlvlist_copy(cur->item->data); 1368 cur1->data = aim_tlvlist_copy(cur->item->data);
1391 } 1369 }
1392 1370
1393 } else if (cur->action == AIM_CB_SSI_DEL) { 1371 } else if (cur->action == AIM_CB_SSI_DEL) {
1394 /* Add the item to the items list */ 1372 /* Add the item back into the local list */
1395 aim_tlvlist_t *data; 1373 aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
1396 data = aim_tlvlist_copy(cur->item->data);
1397 aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, data);
1398 } 1374 }
1399 1375
1400 } else { 1376 } else {
1401 /* Do the exact opposite */ 1377 /* Do the exact opposite */
1402 if (cur->action == AIM_CB_SSI_ADD) { 1378 if (cur->action == AIM_CB_SSI_ADD) {
1403 /* Add the item to the items list */ 1379 /* Add the item to the official list */
1404 aim_tlvlist_t *data; 1380 aim_ssi_itemlist_add(&sess->ssi.official, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data);
1405 data = aim_tlvlist_copy(cur->item->data);
1406 aim_ssi_itemlist_add(&sess->ssi.official, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, data);
1407 1381
1408 } else if (cur->action == AIM_CB_SSI_MOD) { 1382 } else if (cur->action == AIM_CB_SSI_MOD) {
1409 /* Replace the old item with the new item in the items list */ 1383 /* Replace the old item with the new item in the items list */
1410 struct aim_ssi_item *cur1; 1384 struct aim_ssi_item *cur1;
1411 if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) { 1385 if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) {