Changeset c0b1a40
- Timestamp:
- May 5, 2009, 1:16:07 PM (16 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- fa8f439
- Parents:
- 1e6e74e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
aim.c
rc675b39 rc0b1a40 63 63 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...); 64 64 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...); 65 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...);66 65 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); 67 66 int logout(aim_session_t *sess); … … 82 81 /* static void printuserflags(fu16_t flags); */ 83 82 static int faimtest_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...); 84 static int faimtest_handlecmd(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, const char *tmpstr);85 83 static int faimtest_parse_incoming_im_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args); 86 84 static int faimtest_parse_incoming_im_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args); … … 1165 1163 } 1166 1164 1167 #if 01168 static int faimtest_handlecmd(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, const char *tmpstr)1169 {1170 struct owlfaim_priv *priv = (struct owlfaim_priv *)sess->aux_data;1171 1172 if (!strncmp(tmpstr, "disconnect", 10)) {1173 logout(sess);1174 } else if (strstr(tmpstr, "goodday")) {1175 /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK, "Good day to you too."); */1176 } else if (strstr(tmpstr, "haveicon") && priv->buddyicon) {1177 struct aim_sendimext_args args;1178 /* static const char iconmsg[] = {"I have an icon"}; */1179 static const char iconmsg[] = {""};1180 1181 args.destsn = userinfo->sn;1182 args.flags = AIM_IMFLAGS_HASICON;1183 args.msg = iconmsg;1184 args.msglen = strlen(iconmsg);1185 args.iconlen = priv->buddyiconlen;1186 args.iconstamp = priv->buddyiconstamp;1187 args.iconsum = priv->buddyiconsum;1188 1189 /* aim_send_im_ext(sess, &args); */1190 1191 } else if (strstr(tmpstr, "sendbin")) {1192 struct aim_sendimext_args args;1193 static const unsigned char data[] = {1194 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,1195 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,1196 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,1197 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,1198 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,1199 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,1200 };1201 1202 /*1203 * I put this here as a demonstration of how to send1204 * arbitrary binary data via OSCAR ICBM's without the need1205 * for escape or baseN encoding of any sort.1206 *1207 * Apparently if you set the charset to something WinAIM1208 * doesn't recognize, it will completly ignore the message.1209 * That is, it will not display anything in the conversation1210 * window for the user that recieved it.1211 *1212 * HOWEVER, if they do not have a conversation window open1213 * for you, a new one will be created, but it will not have1214 * any messages in it. Therefore sending these things could1215 * be a great way to seemingly subliminally convince people1216 * to talk to you...1217 *1218 */1219 args.destsn = userinfo->sn;1220 /* args.flags = AIM_IMFLAGS_CUSTOMCHARSET; */1221 args.charset = args.charsubset = 0x4242;1222 args.msg = data;1223 args.msglen = sizeof(data);1224 /* aim_send_im_ext(sess, &args); */1225 } else if (strstr(tmpstr, "sendmulti")) {1226 struct aim_sendimext_args args;1227 aim_mpmsg_t mpm;1228 static const fu16_t unidata[] = { /* "UNICODE." */1229 0x0055, 0x004e, 0x0049, 0x0043,1230 0x004f, 0x0044, 0x0045, 0x002e,1231 };1232 static const int unidatalen = 8;1233 1234 /*1235 * This is how multipart messages should be sent.1236 *1237 * This should render as:1238 * "Part 1, ASCII. UNICODE.Part 3, ASCII. "1239 */1240 1241 aim_mpmsg_init(sess, &mpm);1242 aim_mpmsg_addascii(sess, &mpm, "Part 1, ASCII. ");1243 aim_mpmsg_addunicode(sess, &mpm, unidata, unidatalen);1244 aim_mpmsg_addascii(sess, &mpm, "Part 3, ASCII. ");1245 1246 args.destsn = userinfo->sn;1247 args.flags = AIM_IMFLAGS_MULTIPART;1248 args.mpmsg = &mpm;1249 1250 /* aim_send_im_ext(sess, &args); */1251 1252 aim_mpmsg_free(sess, &mpm);1253 1254 } else if (strstr(tmpstr, "sendprebin")) {1255 static const unsigned char data[] = {1256 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,1257 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,1258 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,1259 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,1260 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,1261 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,1262 };1263 struct aim_sendimext_args args;1264 aim_mpmsg_t mpm;1265 1266 /*1267 * This demonstrates sending a human-readable preamble,1268 * and then arbitrary binary data.1269 *1270 * This means that you can very inconspicuously send binary1271 * attachments to other users. In WinAIM, this appears as1272 * though it only had the ASCII portion.1273 *1274 */1275 1276 aim_mpmsg_init(sess, &mpm);1277 aim_mpmsg_addascii(sess, &mpm, "This message has binary data.");1278 aim_mpmsg_addraw(sess, &mpm, 0x4242, 0x4242, data, sizeof(data));1279 1280 args.destsn = userinfo->sn;1281 args.flags = AIM_IMFLAGS_MULTIPART;1282 args.mpmsg = &mpm;1283 1284 /* aim_send_im_ext(sess, &args); */1285 aim_mpmsg_free(sess, &mpm);1286 1287 } else if (strstr(tmpstr, "havefeat")) {1288 struct aim_sendimext_args args;1289 static const char featmsg[] = {"I have nifty features."};1290 fu8_t features[] = {0x01, 0x01, 0x01, 0x02, 0x42, 0x43, 0x44, 0x45};1291 1292 args.destsn = userinfo->sn;1293 args.flags = AIM_IMFLAGS_CUSTOMFEATURES;1294 args.msg = featmsg;1295 args.msglen = strlen(featmsg);1296 args.features = features;1297 args.featureslen = sizeof(features);1298 1299 /* aim_send_im_ext(sess, &args); */1300 } else if (strstr(tmpstr, "sendicon") && priv->buddyicon) {1301 /* aim_send_icon(sess, userinfo->sn, priv->buddyicon, priv->buddyiconlen, priv->buddyiconstamp, priv->buddyiconsum); */1302 } else if (strstr(tmpstr, "warnme")) {1303 /* printf("icbm: sending non-anon warning\n"); */1304 /* aim_send_warning(sess, conn, userinfo->sn, 0); */1305 } else if (strstr(tmpstr, "anonwarn")) {1306 /* printf("icbm: sending anon warning\n"); */1307 /* aim_send_warning(sess, conn, userinfo->sn, AIM_WARN_ANON); */1308 } else if (strstr(tmpstr, "setdirectoryinfo")) {1309 /* printf("icbm: sending backwards profile data\n"); */1310 aim_setdirectoryinfo(sess, conn, "tsrif", "elddim", "tsal", "nediam", "emankcin", "teerts", "ytic", "etats", "piz", 0, 1);1311 } else if (strstr(tmpstr, "setinterests")) {1312 /* printf("icbm: setting fun interests\n"); */1313 aim_setuserinterests(sess, conn, "interest1", "interest2", "interest3", "interest4", "interest5", 1);1314 } else if (!strncmp(tmpstr, "open chatnav", 12)) {1315 aim_reqservice(sess, conn, AIM_CONN_TYPE_CHATNAV);1316 } else if (!strncmp(tmpstr, "create", 6)) {1317 aim_chatnav_createroom(sess,aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV), (strlen(tmpstr) < 7)?"WorldDomination":tmpstr+7, 0x0004);1318 } else if (!strncmp(tmpstr, "close chatnav", 13)) {1319 aim_conn_t *chatnavconn;1320 if ((chatnavconn = aim_getconn_type(sess, AIM_CONN_TYPE_CHATNAV)))1321 aim_conn_kill(sess, &chatnavconn);1322 } else if (!strncmp(tmpstr, "join", 4)) {1323 aim_chat_join(sess, conn, 0x0004, "worlddomination", 0x0000);1324 } else if (!strncmp(tmpstr, "leave", 5)) {1325 aim_chat_leaveroom(sess, "worlddomination");1326 } else if (!strncmp(tmpstr, "getinfo", 7)) {1327 aim_getinfo(sess, conn, "midendian", AIM_GETINFO_GENERALINFO);1328 aim_getinfo(sess, conn, "midendian", AIM_GETINFO_AWAYMESSAGE);1329 aim_getinfo(sess, conn, "midendian", AIM_GETINFO_CAPABILITIES);1330 } else if(strstr(tmpstr, "lookup")) {1331 /* aim_usersearch_address(sess, conn, "mid@auk.cx"); */1332 } else if (!strncmp(tmpstr, "reqsendmsg", 10)) {1333 /* aim_send_im(sess, priv->ohcaptainmycaptain, 0, "sendmsg 7900"); */1334 } else if (!strncmp(tmpstr, "reqadmin", 8)) {1335 aim_reqservice(sess, conn, AIM_CONN_TYPE_AUTH);1336 } else if (!strncmp(tmpstr, "changenick", 10)) {1337 aim_admin_setnick(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), "diputs8 1");1338 } else if (!strncmp(tmpstr, "reqconfirm", 10)) {1339 aim_admin_reqconfirm(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH));1340 } else if (!strncmp(tmpstr, "reqemail", 8)) {1341 aim_admin_getinfo(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), 0x0011);1342 } else if (!strncmp(tmpstr, "changepass", 8)) {1343 aim_admin_changepasswd(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), "NEWPASSWORD", "OLDPASSWORD");1344 } else if (!strncmp(tmpstr, "setemail", 8)) {1345 aim_admin_setemail(sess, aim_getconn_type(sess, AIM_CONN_TYPE_AUTH), "NEWEMAILADDRESS");1346 } else if (!strncmp(tmpstr, "sendmsg", 7)) {1347 int i;1348 1349 i = atoi(tmpstr+8);1350 if (i < 10000) {1351 char *newbuf;1352 int z;1353 1354 newbuf = owl_malloc(i+1);1355 for (z = 0; z < i; z++)1356 newbuf[z] = (z % 10)+0x30;1357 newbuf[i] = '\0';1358 /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf); */1359 owl_free(newbuf);1360 }1361 } else if (strstr(tmpstr, "seticqstatus")) {1362 aim_setextstatus(sess, AIM_ICQ_STATE_DND);1363 } else if (strstr(tmpstr, "rtfmsg")) {1364 static const char rtfmsg[] = {"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}{\\f1\\froman\\fprq2\\fcharset0 Georgia;}{\\f2\\fmodern\\fprq1\\fcharset0 MS Mincho;}{\\f3\\froman\\fprq2\\fcharset2 Symbol;}}\\viewkind4\\uc1\\pard\\f0\\fs20 Test\\f1 test\\f2\fs44 test\\f3\\fs20 test\\f0\\par}"};1365 struct aim_sendrtfmsg_args rtfargs;1366 1367 memset(&rtfargs, 0, sizeof(rtfargs));1368 rtfargs.destsn = userinfo->sn;1369 rtfargs.fgcolor = 0xffffffff;1370 rtfargs.bgcolor = 0x00000000;1371 rtfargs.rtfmsg = rtfmsg;1372 /* aim_send_rtfmsg(sess, &rtfargs); */1373 } else {1374 /* printf("unknown command.\n"); */1375 aim_add_buddy(sess, conn, userinfo->sn);1376 }1377 1378 return 0;1379 }1380 #endif1381 1382 1165 /* 1383 1166 * Channel 1: Standard Message … … 2172 1955 } 2173 1956 2174 static int faimtest_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...)2175 {2176 fu16_t type;2177 va_list ap;2178 2179 va_start(ap, fr);2180 type = (fu16_t)va_arg(ap, unsigned int);2181 2182 owl_function_debugmsg("in faimtest_chatnav_info");2183 2184 if (type == 0x0002) {2185 int maxrooms;2186 struct aim_chat_exchangeinfo *exchanges;2187 int exchangecount;2188 /* int i; */2189 2190 maxrooms = va_arg(ap, int);2191 exchangecount = va_arg(ap, int);2192 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *);2193 va_end(ap);2194 2195 /*2196 printf("chat info: Chat Rights:\n");2197 printf("chat info: \tMax Concurrent Rooms: %d\n", maxrooms);2198 printf("chat info: \tExchange List: (%d total)\n", exchangecount);2199 for (i = 0; i < exchangecount; i++) {2200 printf("chat info: \t\t%x: %s (%s/%s) (0x%04x = %s%s%s%s)\n",2201 exchanges[i].number,2202 exchanges[i].name,2203 exchanges[i].charset1,2204 exchanges[i].lang1,2205 exchanges[i].flags,2206 (exchanges[i].flags & AIM_CHATROOM_FLAG_EVILABLE) ? "Evilable, " : "",2207 (exchanges[i].flags & AIM_CHATROOM_FLAG_NAV_ONLY) ? "Nav Only, " : "",2208 (exchanges[i].flags & AIM_CHATROOM_FLAG_INSTANCING_ALLOWED) ? "Instancing allowed, " : "",2209 (exchanges[i].flags & AIM_CHATROOM_FLAG_OCCUPANT_PEEK_ALLOWED) ? "Occupant peek allowed, " : "");2210 }2211 */2212 } else if (type == 0x0008) {2213 char *fqcn, *name, *ck;2214 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange;2215 fu8_t createperms;2216 fu32_t createtime;2217 2218 fqcn = va_arg(ap, char *);2219 instance = (fu16_t)va_arg(ap, unsigned int);2220 exchange = (fu16_t)va_arg(ap, unsigned int);2221 flags = (fu16_t)va_arg(ap, unsigned int);2222 createtime = va_arg(ap, fu32_t);2223 maxmsglen = (fu16_t)va_arg(ap, unsigned int);2224 maxoccupancy = (fu16_t)va_arg(ap, unsigned int);2225 createperms = (fu8_t)va_arg(ap, unsigned int);2226 unknown = (fu16_t)va_arg(ap, unsigned int);2227 name = va_arg(ap, char *);2228 ck = va_arg(ap, char *);2229 va_end(ap);2230 2231 /* printf("received room create reply for %s/0x%04x\n", fqcn, exchange); */2232 2233 } else {2234 va_end(ap);2235 /* printf("chatnav info: unknown type (%04x)\n", type); */2236 }2237 2238 return 1;2239 }2240 2241 1957 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) 2242 1958 { … … 2258 1974 chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); 2259 1975 */ 2260 return(1);2261 }2262 2263 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...)2264 {2265 owl_function_debugmsg("faimtest_conninitdone_chatnav:");2266 2267 /* aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); */2268 /* aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); */2269 2270 aim_clientready(sess, fr->conn);2271 2272 aim_chatnav_reqrights(sess, fr->conn);2273 2274 1976 return(1); 2275 1977 } … … 2327 2029 } 2328 2030 } 2329 2330 2331 /**********************************************************************************/2332 2333 #if 02334 static int faimtest_ssi_rerequestdata(aim_session_t *sess, aim_frame_t *fr, ...)2335 {2336 aim_ssi_reqdata(sess);2337 return(0);2338 }2339 2340 static int faimtest_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...)2341 {2342 /* GaimConnection *gc = sess->aux_data; */2343 /* OscarData *od = gc->proto_data; */2344 va_list ap;2345 fu16_t reason;2346 2347 va_start(ap, fr);2348 reason = (fu16_t)va_arg(ap, unsigned int);2349 va_end(ap);2350 2351 owl_function_debugmsg("faimtest_ssi_parseerr: ssi: SNAC error %hu", reason);2352 2353 if (reason == 0x0005) {2354 owl_function_error("faimtest_ssi_parseerr: unable to retrieve buddy list");2355 }2356 2357 /* Activate SSI */2358 /* Sending the enable causes other people to be able to see you, and you to see them */2359 /* Make sure your privacy setting/invisibility is set how you want it before this! */2360 owl_function_debugmsg("faimtest_ssi_parseerr: ssi: activating server-stored buddy list");2361 aim_ssi_enable(sess);2362 2363 return(1);2364 }2365 2366 static int faimtest_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...)2367 {2368 /* GaimConnection *gc = sess->aux_data; */2369 /* OscarData *od = (OscarData *)gc->proto_data; */2370 int numtypes, i;2371 fu16_t *maxitems;2372 va_list ap;2373 2374 va_start(ap, fr);2375 numtypes = va_arg(ap, int);2376 maxitems = va_arg(ap, fu16_t *);2377 va_end(ap);2378 2379 owl_function_debugmsg("faimtest_ssi_parserights: ");2380 for (i=0; i<numtypes; i++) {2381 owl_function_debugmsg(" max type 0x%04x=%hd,", i, maxitems[i]);2382 }2383 2384 /*2385 if (numtypes >= 0) od->rights.maxbuddies = maxitems[0];2386 if (numtypes >= 1) od->rights.maxgroups = maxitems[1];2387 if (numtypes >= 2) od->rights.maxpermits = maxitems[2];2388 if (numtypes >= 3) od->rights.maxdenies = maxitems[3];2389 */2390 2391 return(1);2392 }2393 2394 static int faimtest_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...)2395 {2396 /* GaimConnection *gc = sess->aux_data; */2397 /* GaimAccount *account = gaim_connection_get_account(gc); */2398 /* OscarData *od = (OscarData *)gc->proto_data; */2399 struct aim_ssi_item *curitem;2400 int tmp;2401 int export = FALSE;2402 /* XXX - use these?2403 va_list ap;2404 2405 va_start(ap, fr);2406 fmtver = (fu16_t)va_arg(ap, int);2407 numitems = (fu16_t)va_arg(ap, int);2408 items = va_arg(ap, struct aim_ssi_item);2409 timestamp = va_arg(ap, fu32_t);2410 va_end(ap); */2411 2412 owl_function_debugmsg("faimtest_ssi_parselist: syncing local list and server list");2413 2414 /* Clean the buddy list */2415 aim_ssi_cleanlist(sess);2416 2417 /* Add from server list to local list */2418 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) {2419 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL)))2420 switch (curitem->type) {2421 case 0x0000: { /* Buddy */2422 if (curitem->name) {2423 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name);2424 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL;2425 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name);2426 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL;2427 GaimBuddy *buddy = gaim_find_buddy(gc->account, curitem->name);2428 /* Should gname be freed here? -- elb */2429 /* Not with the current code, but that might be cleaner -- med */2430 free(alias);2431 if (buddy) {2432 /* Get server stored alias */2433 if (alias_utf8) {2434 g_free(buddy->alias);2435 buddy->alias = g_strdup(alias_utf8);2436 }2437 } else {2438 GaimGroup *g;2439 buddy = gaim_buddy_new(gc->account, curitem->name, alias_utf8);2440 2441 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {2442 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));2443 gaim_blist_add_group(g, NULL);2444 }2445 2446 gaim_debug(GAIM_DEBUG_INFO, "oscar",2447 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans"));2448 gaim_blist_add_buddy(buddy, NULL, g, NULL);2449 export = TRUE;2450 }2451 g_free(gname_utf8);2452 g_free(alias_utf8);2453 }2454 } break;2455 2456 case 0x0001: { /* Group */2457 /* Shouldn't add empty groups */2458 } break;2459 2460 case 0x0002: { /* Permit buddy */2461 if (curitem->name) {2462 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */2463 GSList *list;2464 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next);2465 if (!list) {2466 gaim_debug(GAIM_DEBUG_INFO, "oscar",2467 "ssi: adding permit buddy %s to local list\n", curitem->name);2468 gaim_privacy_permit_add(account, curitem->name, TRUE);2469 export = TRUE;2470 }2471 }2472 } break;2473 2474 case 0x0003: { /* Deny buddy */2475 if (curitem->name) {2476 GSList *list;2477 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next);2478 if (!list) {2479 gaim_debug(GAIM_DEBUG_INFO, "oscar",2480 "ssi: adding deny buddy %s to local list\n", curitem->name);2481 gaim_privacy_deny_add(account, curitem->name, TRUE);2482 export = TRUE;2483 }2484 }2485 } break;2486 2487 case 0x0004: { /* Permit/deny setting */2488 if (curitem->data) {2489 fu8_t permdeny;2490 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) {2491 gaim_debug(GAIM_DEBUG_INFO, "oscar",2492 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny);2493 account->perm_deny = permdeny;2494 if (od->icq && account->perm_deny == 0x03) {2495 serv_set_away(gc, "Invisible", "");2496 }2497 export = TRUE;2498 }2499 }2500 } break;2501 2502 case 0x0005: { /* Presence setting */2503 /* We don't want to change Gaim's setting because it applies to all accounts */2504 } break;2505 } /* End of switch on curitem->type */2506 } /* End of for loop */2507 2508 /* If changes were made, then flush buddy list to file */2509 if (export)2510 gaim_blist_save();2511 2512 { /* Add from local list to server list */2513 GaimBlistNode *gnode, *cnode, *bnode;2514 GaimGroup *group;2515 GaimBuddy *buddy;2516 GaimBuddyList *blist;2517 GSList *cur;2518 2519 /* Buddies */2520 if ((blist = gaim_get_blist()))2521 for (gnode = blist->root; gnode; gnode = gnode->next) {2522 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))2523 continue;2524 group = (GaimGroup *)gnode;2525 for (cnode = gnode->child; cnode; cnode = cnode->next) {2526 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode))2527 continue;2528 for (bnode = cnode->child; bnode; bnode = bnode->next) {2529 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))2530 continue;2531 buddy = (GaimBuddy *)bnode;2532 if (buddy->account == gc->account) {2533 const char *servernick = gaim_buddy_get_setting(buddy, "servernick");2534 if (servernick)2535 serv_got_alias(gc, buddy->name, servernick);2536 2537 if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) {2538 /* Store local alias on server */2539 char *alias = aim_ssi_getalias(sess->ssi.local, group->name, buddy->name);2540 if (!alias && buddy->alias && strlen(buddy->alias))2541 aim_ssi_aliasbuddy(sess, group->name, buddy->name, buddy->alias);2542 free(alias);2543 } else {2544 gaim_debug(GAIM_DEBUG_INFO, "oscar",2545 "ssi: adding buddy %s from local list to server list\n", buddy->name);2546 aim_ssi_addbuddy(sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0);2547 }2548 }2549 }2550 }2551 }2552 2553 /* Permit list */2554 if (gc->account->permit) {2555 for (cur=gc->account->permit; cur; cur=cur->next)2556 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) {2557 gaim_debug(GAIM_DEBUG_INFO, "oscar",2558 "ssi: adding permit %s from local list to server list\n", (char *)cur->data);2559 aim_ssi_addpermit(sess, cur->data);2560 }2561 }2562 2563 /* Deny list */2564 if (gc->account->deny) {2565 for (cur=gc->account->deny; cur; cur=cur->next)2566 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) {2567 gaim_debug(GAIM_DEBUG_INFO, "oscar",2568 "ssi: adding deny %s from local list to server list\n", (char *)cur->data);2569 aim_ssi_adddeny(sess, cur->data);2570 }2571 }2572 /* Presence settings (idle time visibility) */2573 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF)2574 if (!(tmp & 0x400))2575 aim_ssi_setpresence(sess, tmp | 0x400);2576 } /* end adding buddies from local list to server list */2577 2578 /* Set our ICQ status */2579 if (od->icq && !gc->away) {2580 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL);2581 }2582 2583 /* Activate SSI */2584 /* Sending the enable causes other people to be able to see you, and you to see them */2585 /* Make sure your privacy setting/invisibility is set how you want it before this! */2586 gaim_debug(GAIM_DEBUG_INFO, "oscar", "ssi: activating server-stored buddy list\n");2587 aim_ssi_enable(sess);2588 2589 return 1;2590 }2591 2592 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...)2593 {2594 GaimConnection *gc = sess->aux_data;2595 va_list ap;2596 struct aim_ssi_tmp *retval;2597 2598 va_start(ap, fr);2599 retval = va_arg(ap, struct aim_ssi_tmp *);2600 va_end(ap);2601 2602 while (retval) {2603 gaim_debug(GAIM_DEBUG_MISC, "oscar",2604 "ssi: status is 0x%04hx for a 0x%04hx action with name %s\n", retval->ack, retval->action, retval->item ? (retval->item->name ? retval->item->name : "no name") : "no item");2605 2606 if (retval->ack != 0xffff)2607 switch (retval->ack) {2608 case 0x0000: { /* added successfully */2609 } break;2610 2611 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */2612 gchar *buf;2613 buf = g_strdup_printf(_("Could not add the buddy %s because you have too many buddies in your buddy list. Please remove one and try again."), (retval->name ? retval->name : _("(no name)")));2614 gaim_notify_error(gc, NULL, _("Unable To Add"), buf);2615 g_free(buf);2616 }2617 2618 case 0x000e: { /* buddy requires authorization */2619 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name))2620 gaim_auth_sendrequest(gc, retval->name);2621 } break;2622 2623 default: { /* La la la */2624 gchar *buf;2625 gaim_debug(GAIM_DEBUG_ERROR, "oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack);2626 buf = g_strdup_printf(_("Could not add the buddy %s for an unknown reason. The most common reason for this is that you have the maximum number of allowed buddies in your buddy list."), (retval->name ? retval->name : _("(no name)")));2627 gaim_notify_error(gc, NULL, _("Unable To Add"), buf);2628 g_free(buf);2629 /* XXX - Should remove buddy from local list */2630 } break;2631 }2632 2633 retval = retval->next;2634 }2635 2636 return 1;2637 }2638 2639 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...)2640 {2641 GaimConnection *gc = sess->aux_data;2642 va_list ap;2643 char *sn, *msg;2644 gchar *dialog_msg, *nombre;2645 struct name_data *data;2646 GaimBuddy *buddy;2647 2648 va_start(ap, fr);2649 sn = va_arg(ap, char *);2650 msg = va_arg(ap, char *);2651 va_end(ap);2652 2653 gaim_debug(GAIM_DEBUG_INFO, "oscar",2654 "ssi: %s has given you permission to add him to your buddy list\n", sn);2655 2656 buddy = gaim_find_buddy(gc->account, sn);2657 if (buddy && (gaim_get_buddy_alias_only(buddy)))2658 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy));2659 else2660 nombre = g_strdup(sn);2661 2662 dialog_msg = g_strdup_printf(_("The user %s has given you permission to add you to their buddy list. Do you want to add them?"), nombre);2663 data = g_new(struct name_data, 1);2664 data->gc = gc;2665 data->name = g_strdup(sn);2666 data->nick = NULL;2667 2668 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg,2669 0, data,2670 G_CALLBACK(gaim_icq_buddyadd),2671 G_CALLBACK(oscar_free_name_data));2672 2673 g_free(dialog_msg);2674 g_free(nombre);2675 2676 return 1;2677 }2678 2679 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...)2680 {2681 GaimConnection *gc = sess->aux_data;2682 va_list ap;2683 char *sn, *msg;2684 gchar *dialog_msg, *nombre;2685 struct name_data *data;2686 GaimBuddy *buddy;2687 2688 va_start(ap, fr);2689 sn = va_arg(ap, char *);2690 msg = va_arg(ap, char *);2691 va_end(ap);2692 2693 gaim_debug(GAIM_DEBUG_INFO, "oscar",2694 "ssi: received authorization request from %s\n", sn);2695 2696 buddy = gaim_find_buddy(gc->account, sn);2697 if (buddy && (gaim_get_buddy_alias_only(buddy)))2698 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy));2699 else2700 nombre = g_strdup(sn);2701 2702 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given."));2703 data = g_new(struct name_data, 1);2704 data->gc = gc;2705 data->name = g_strdup(sn);2706 data->nick = NULL;2707 2708 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg,2709 0, data, 2,2710 _("Authorize"), G_CALLBACK(gaim_auth_grant),2711 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt));2712 2713 g_free(dialog_msg);2714 g_free(nombre);2715 2716 return 1;2717 }2718 2719 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...)2720 {2721 GaimConnection *gc = sess->aux_data;2722 va_list ap;2723 char *sn, *msg;2724 gchar *dialog_msg, *nombre;2725 fu8_t reply;2726 GaimBuddy *buddy;2727 2728 va_start(ap, fr);2729 sn = va_arg(ap, char *);2730 reply = (fu8_t)va_arg(ap, int);2731 msg = va_arg(ap, char *);2732 va_end(ap);2733 2734 gaim_debug(GAIM_DEBUG_INFO, "oscar",2735 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply);2736 2737 buddy = gaim_find_buddy(gc->account, sn);2738 if (buddy && (gaim_get_buddy_alias_only(buddy)))2739 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy));2740 else2741 nombre = g_strdup(sn);2742 2743 if (reply) {2744 /* Granted */2745 dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your buddy list."), nombre);2746 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg);2747 } else {2748 /* Denied */2749 dialog_msg = g_strdup_printf(_("The user %s has denied your request to add them to your buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given."));2750 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg);2751 }2752 g_free(dialog_msg);2753 g_free(nombre);2754 2755 return 1;2756 }2757 2758 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...)2759 {2760 GaimConnection *gc = sess->aux_data;2761 va_list ap;2762 char *sn;2763 GaimBuddy *buddy;2764 2765 va_start(ap, fr);2766 sn = va_arg(ap, char *);2767 va_end(ap);2768 2769 buddy = gaim_find_buddy(gc->account, sn);2770 gaim_debug(GAIM_DEBUG_INFO, "oscar",2771 "ssi: %s added you to their buddy list\n", sn);2772 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL);2773 2774 return 1;2775 }2776 #endif
Note: See TracChangeset
for help on using the changeset viewer.