| 1438 } |
1443 } |
| 1439 |
1444 |
| 1440 return 1; |
1445 return 1; |
| 1441 } |
1446 } |
| 1442 |
1447 |
| |
1448 static void gaim_icq_authgrant(gpointer w, struct icq_auth *data) { |
| |
1449 char *uin, message; |
| |
1450 struct oscar_data *od = (struct oscar_data *)data->gc->proto_data; |
| |
1451 uin = g_strdup_printf("%d", data->uin); |
| |
1452 message = 0; |
| |
1453 aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHGRANTED, &message); |
| |
1454 show_got_added(data->gc, NULL, uin, NULL, NULL); |
| |
1455 g_free(uin); |
| |
1456 data->uin = 0; |
| |
1457 } |
| |
1458 |
| |
1459 static void gaim_icq_authdeny(gpointer w, struct icq_auth *data) { |
| |
1460 if (data->uin) { |
| |
1461 char *uin, *message; |
| |
1462 struct oscar_data *od = (struct oscar_data *)data->gc->proto_data; |
| |
1463 uin = g_strdup_printf("%d", data->uin); |
| |
1464 message = g_strdup_printf("No reason given."); |
| |
1465 aim_send_im_ch4(od->sess, uin, AIM_ICQMSG_AUTHDENIED, message); |
| |
1466 g_free(uin); |
| |
1467 g_free(message); |
| |
1468 } |
| |
1469 g_free(data); |
| |
1470 } |
| |
1471 |
| |
1472 /* |
| |
1473 * For when other people ask you for authorization |
| |
1474 */ |
| |
1475 static void gaim_icq_authask(struct gaim_connection *gc, fu32_t uin, char *msg) { |
| |
1476 struct icq_auth *data = g_new(struct icq_auth, 1); |
| |
1477 /* The first 6 chars of the message are some type of alien gibberish, so skip them */ |
| |
1478 char *dialog_msg = g_strdup_printf("The user %d wants to add you to their buddy list for the following reason:\n\n%s", uin, (msg && strlen(msg)>6) ? msg+6 : "No reason given."); |
| |
1479 debug_printf("Received an authorization request from UIN %ld\n", uin); |
| |
1480 data->gc = gc; |
| |
1481 data->uin = uin; |
| |
1482 do_ask_dialog(dialog_msg, data, gaim_icq_authgrant, gaim_icq_authdeny); |
| |
1483 g_free(dialog_msg); |
| |
1484 } |
| |
1485 |
| |
1486 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args) { |
| |
1487 struct gaim_connection *gc = sess->aux_data; |
| |
1488 |
| |
1489 switch (args->type) { |
| |
1490 case 0x0006: { /* Someone requested authorization */ |
| |
1491 gaim_icq_authask(gc, args->uin, args->msg); |
| |
1492 } break; |
| |
1493 |
| |
1494 case 0x0007: { /* Someone has denied you authorization */ |
| |
1495 char *dialog_msg; |
| |
1496 dialog_msg = g_strdup_printf(_("The user %d has denied your request to add them to your contact list for the following reason:\n\n"), args->uin, args->msg ? args->msg : _("No reason given.")); |
| |
1497 do_error_dialog(dialog_msg, _("Gaim - ICQ Authorization Denied")); |
| |
1498 g_free(dialog_msg); |
| |
1499 } break; |
| |
1500 |
| |
1501 case 0x0008: { /* Someone has granted you authorization */ |
| |
1502 char *dialog_msg; |
| |
1503 dialog_msg = g_strdup_printf(_("The user %d has granted your request to add them to your contact list."), args->uin); |
| |
1504 do_error_dialog(dialog_msg, _("Gaim - ICQ Authorization Granted")); |
| |
1505 g_free(dialog_msg); |
| |
1506 } break; |
| |
1507 |
| |
1508 case 0x0012: { |
| |
1509 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
| |
1510 } break; |
| |
1511 |
| |
1512 default: { |
| |
1513 debug_printf("Received a channel 4 message of unknown type (type 0x%04d).\n", args->type); |
| |
1514 } break; |
| |
1515 } |
| |
1516 |
| |
1517 return 1; |
| |
1518 } |
| 1443 |
1519 |
| 1444 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
1520 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 1445 int channel, ret = 0; |
1521 int channel, ret = 0; |
| 1446 aim_userinfo_t *userinfo; |
1522 aim_userinfo_t *userinfo; |
| 1447 va_list ap; |
1523 va_list ap; |
| 1448 |
1524 |
| 1449 va_start(ap, fr); |
1525 va_start(ap, fr); |
| 1450 channel = va_arg(ap, int); |
1526 channel = va_arg(ap, int); |
| 1451 userinfo = va_arg(ap, aim_userinfo_t *); |
1527 userinfo = va_arg(ap, aim_userinfo_t *); |
| 1452 |
1528 |
| 1453 /* channel 1: standard message */ |
1529 switch (channel) { |
| 1454 if (channel == 1) { |
1530 case 1: { /* standard message */ |
| 1455 struct aim_incomingim_ch1_args *args; |
1531 struct aim_incomingim_ch1_args *args; |
| 1456 |
1532 args = va_arg(ap, struct aim_incomingim_ch1_args *); |
| 1457 args = va_arg(ap, struct aim_incomingim_ch1_args *); |
1533 ret = incomingim_chan1(sess, fr->conn, userinfo, args); |
| 1458 |
1534 } break; |
| 1459 ret = incomingim_chan1(sess, fr->conn, userinfo, args); |
1535 |
| 1460 |
1536 case 2: { /* rendevous */ |
| 1461 } else if (channel == 2) { |
1537 struct aim_incomingim_ch2_args *args; |
| 1462 struct aim_incomingim_ch2_args *args; |
1538 args = va_arg(ap, struct aim_incomingim_ch2_args *); |
| 1463 |
1539 ret = incomingim_chan2(sess, fr->conn, userinfo, args); |
| 1464 args = va_arg(ap, struct aim_incomingim_ch2_args *); |
1540 } break; |
| 1465 |
1541 |
| 1466 ret = incomingim_chan2(sess, fr->conn, userinfo, args); |
1542 case 4: { /* ICQ */ |
| 1467 } else if (channel == 3) { |
1543 struct aim_incomingim_ch4_args *args; |
| 1468 printf("Chan 3\n"); |
1544 args = va_arg(ap, struct aim_incomingim_ch4_args *); |
| 1469 } else if (channel == 4) { |
1545 ret = incomingim_chan4(sess, fr->conn, userinfo, args); |
| 1470 printf("Chan 4\n"); |
1546 } break; |
| |
1547 |
| |
1548 default: { |
| |
1549 debug_printf("ICBM received on unsupported channel (channel 0x%04d).", channel); |
| |
1550 } break; |
| 1471 } |
1551 } |
| 1472 |
1552 |
| 1473 va_end(ap); |
1553 va_end(ap); |
| 1474 |
1554 |
| 1475 return ret; |
1555 return ret; |
| 2267 |
2347 |
| 2268 va_start(ap, fr); |
2348 va_start(ap, fr); |
| 2269 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
2349 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
| 2270 va_end(ap); |
2350 va_end(ap); |
| 2271 |
2351 |
| 2272 if (msg->type == 0x0001) { |
2352 debug_printf("Received offline message of type 0x%04x\n", msg->type); |
| 2273 char sender[32]; |
2353 |
| 2274 char *tmp = g_strdup(msg->msg); |
2354 switch (msg->type) { |
| 2275 time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
2355 case 0x0001: { /* Basic offline message */ |
| 2276 g_snprintf(sender, sizeof(sender), "%lu", msg->sender); |
2356 char sender[32]; |
| 2277 strip_linefeed(tmp); |
2357 char *dialog_msg = g_strdup(msg->msg); |
| 2278 serv_got_im(gc, sender, tmp, 0, t, -1); |
2358 time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
| 2279 g_free(tmp); |
2359 g_snprintf(sender, sizeof(sender), "%lu", msg->sender); |
| 2280 } else { |
2360 strip_linefeed(dialog_msg); |
| 2281 debug_printf("unknown offline message type 0x%04x\n", msg->type); |
2361 serv_got_im(gc, sender, dialog_msg, 0, t, -1); |
| |
2362 g_free(dialog_msg); |
| |
2363 } break; |
| |
2364 |
| |
2365 case 0x0006: { /* Authorization request */ |
| |
2366 gaim_icq_authask(gc, msg->sender, msg->msg); |
| |
2367 } break; |
| |
2368 |
| |
2369 case 0x0007: { /* Someone has denied you authorization */ |
| |
2370 char *dialog_msg; |
| |
2371 dialog_msg = g_strdup_printf(_("The user %d has denied your request to add them to your contact list for the following reason:\n\n"), msg->sender, msg->msg ? msg->msg : _("No reason given.")); |
| |
2372 do_error_dialog(dialog_msg, _("Gaim - ICQ Authorization Denied")); |
| |
2373 g_free(dialog_msg); |
| |
2374 } break; |
| |
2375 |
| |
2376 case 0x0008: { /* Someone has granted you authorization */ |
| |
2377 char *dialog_msg; |
| |
2378 dialog_msg = g_strdup_printf(_("The user %d has granted your request to add them to your contact list."), msg->sender); |
| |
2379 do_error_dialog(dialog_msg, _("Gaim - ICQ Authorization Granted")); |
| |
2380 g_free(dialog_msg); |
| |
2381 } break; |
| |
2382 |
| |
2383 case 0x0012: { |
| |
2384 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
| |
2385 } break; |
| |
2386 |
| |
2387 default: { |
| |
2388 debug_printf("unknown offline message type 0x%04x\n", msg->type); |
| |
2389 } |
| 2282 } |
2390 } |
| 2283 |
2391 |
| 2284 return 1; |
2392 return 1; |
| 2285 } |
2393 } |
| 2286 |
2394 |