Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 5836:09f7f23dc83a
[gaim-migrate @ 6267]
I think I've fixed the negative online time for real, now. Or, at least
reduced the frequency of it happening. Also added the ability to see
iChat's "available" messages.
Sean, I ended up changing more than I thought I would have to, but that's
partially because I like to change things a lot.
If it conflicts or whatever feel free to back it out and I can re-patch it
back in when you're done with your stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 12 Jun 2003 03:27:58 +0000 |
parents | 136f26dcfeda |
children | a48c338dff6c |
comparison
equal
deleted
inserted
replaced
5835:9a08899192ee | 5836:09f7f23dc83a |
---|---|
157 /* Various PRPL-specific buddy info that we want to keep track of */ | 157 /* Various PRPL-specific buddy info that we want to keep track of */ |
158 struct buddyinfo { | 158 struct buddyinfo { |
159 time_t signon; | 159 time_t signon; |
160 int caps; | 160 int caps; |
161 gboolean typingnot; | 161 gboolean typingnot; |
162 gchar *availablemsg; | |
163 | |
164 unsigned long ico_me_len; | |
165 unsigned long ico_me_csum; | |
166 time_t ico_me_time; | |
167 gboolean ico_informed; | |
162 | 168 |
163 unsigned long ico_len; | 169 unsigned long ico_len; |
164 unsigned long ico_csum; | 170 unsigned long ico_csum; |
165 time_t ico_time; | 171 time_t ico_time; |
166 gboolean ico_need; | 172 gboolean ico_need; |
167 | 173 |
168 unsigned long ico_me_len; | |
169 unsigned long ico_me_csum; | |
170 time_t ico_me_time; | |
171 gboolean ico_informed; | |
172 | |
173 fu16_t iconcsumlen; | 174 fu16_t iconcsumlen; |
174 fu8_t iconcsum[30]; | 175 fu8_t *iconcsum; |
175 }; | 176 }; |
176 | 177 |
177 struct name_data { | 178 struct name_data { |
178 GaimConnection *gc; | 179 GaimConnection *gc; |
179 gchar *name; | 180 gchar *name; |
284 static gboolean gaim_icon_timerfunc(gpointer data); | 285 static gboolean gaim_icon_timerfunc(gpointer data); |
285 | 286 |
286 /* prpl actions - remove this at some point */ | 287 /* prpl actions - remove this at some point */ |
287 static void oscar_set_info(GaimConnection *gc, char *text); | 288 static void oscar_set_info(GaimConnection *gc, char *text); |
288 | 289 |
289 static void gaim_free_name_data(struct name_data *data) { | 290 static void oscar_free_name_data(struct name_data *data) { |
290 g_free(data->name); | 291 g_free(data->name); |
291 g_free(data->nick); | 292 g_free(data->nick); |
292 g_free(data); | 293 g_free(data); |
294 } | |
295 | |
296 static void oscar_free_buddyinfo(void *data) { | |
297 struct buddyinfo *bi = data; | |
298 g_free(bi->availablemsg); | |
299 g_free(bi->iconcsum); | |
300 g_free(bi); | |
293 } | 301 } |
294 | 302 |
295 static fu32_t oscar_encoding_check(const char *utf8) | 303 static fu32_t oscar_encoding_check(const char *utf8) |
296 { | 304 { |
297 int i = 0; | 305 int i = 0; |
652 od->icq = TRUE; | 660 od->icq = TRUE; |
653 } else { | 661 } else { |
654 gc->flags |= OPT_CONN_HTML; | 662 gc->flags |= OPT_CONN_HTML; |
655 gc->flags |= OPT_CONN_AUTO_RESP; | 663 gc->flags |= OPT_CONN_AUTO_RESP; |
656 } | 664 } |
657 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | 665 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
658 | 666 |
659 sess = g_new0(aim_session_t, 1); | 667 sess = g_new0(aim_session_t, 1); |
660 | 668 |
661 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); | 669 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); |
662 aim_setdebuggingcb(sess, oscar_debug); | 670 aim_setdebuggingcb(sess, oscar_debug); |
1785 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | 1793 if (info->present & AIM_USERINFO_PRESENT_IDLE) { |
1786 time(&time_idle); | 1794 time(&time_idle); |
1787 time_idle -= info->idletime*60; | 1795 time_idle -= info->idletime*60; |
1788 } | 1796 } |
1789 | 1797 |
1790 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | 1798 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
1799 signon = info->onlinesince; | |
1800 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
1791 signon = time(NULL) - info->sessionlen; | 1801 signon = time(NULL) - info->sessionlen; |
1792 | 1802 |
1793 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) | 1803 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
1794 gaim_connection_set_display_name(gc, info->sn); | 1804 gaim_connection_set_display_name(gc, info->sn); |
1795 | 1805 |
1801 bi->signon = info->onlinesince ? info->onlinesince : (info->sessionlen + time(NULL)); | 1811 bi->signon = info->onlinesince ? info->onlinesince : (info->sessionlen + time(NULL)); |
1802 if (caps) | 1812 if (caps) |
1803 bi->caps = caps; | 1813 bi->caps = caps; |
1804 bi->typingnot = FALSE; | 1814 bi->typingnot = FALSE; |
1805 bi->ico_informed = FALSE; | 1815 bi->ico_informed = FALSE; |
1816 if (info->availablemsg) { | |
1817 free(bi->availablemsg); | |
1818 bi->availablemsg = g_strdup(info->availablemsg); | |
1819 } | |
1806 | 1820 |
1807 /* Server stored icon stuff */ | 1821 /* Server stored icon stuff */ |
1808 if (info->iconcsumlen) { | 1822 if (info->iconcsumlen) { |
1809 char *b16, *saved_b16; | 1823 char *b16, *saved_b16; |
1810 struct buddy *b; | 1824 struct buddy *b; |
1811 | 1825 |
1826 free(bi->iconcsum); | |
1827 bi->iconcsum = malloc(info->iconcsumlen); | |
1812 memcpy(bi->iconcsum, info->iconcsum, info->iconcsumlen); | 1828 memcpy(bi->iconcsum, info->iconcsum, info->iconcsumlen); |
1813 bi->iconcsumlen = info->iconcsumlen; | 1829 bi->iconcsumlen = info->iconcsumlen; |
1814 b16 = tobase16(bi->iconcsum, bi->iconcsumlen); | 1830 b16 = tobase16(bi->iconcsum, bi->iconcsumlen); |
1815 b = gaim_find_buddy(gc->account, info->sn); | 1831 b = gaim_find_buddy(gc->account, info->sn); |
1816 saved_b16 = gaim_buddy_get_setting(b, "icon_checksum"); | 1832 saved_b16 = gaim_buddy_get_setting(b, "icon_checksum"); |
2422 | 2438 |
2423 static void gaim_auth_request_msgprompt(struct name_data *data) { | 2439 static void gaim_auth_request_msgprompt(struct name_data *data) { |
2424 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), | 2440 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
2425 NULL, _("Please authorize me!"), TRUE, | 2441 NULL, _("Please authorize me!"), TRUE, |
2426 _("OK"), G_CALLBACK(gaim_auth_request), | 2442 _("OK"), G_CALLBACK(gaim_auth_request), |
2427 _("Cancel"), G_CALLBACK(gaim_free_name_data), | 2443 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
2428 data); | 2444 data); |
2429 } | 2445 } |
2430 | 2446 |
2431 static void gaim_auth_dontrequest(struct name_data *data) { | 2447 static void gaim_auth_dontrequest(struct name_data *data) { |
2432 GaimConnection *gc = data->gc; | 2448 GaimConnection *gc = data->gc; |
2434 if (g_list_find(gaim_connections_get_all(), gc)) { | 2450 if (g_list_find(gaim_connections_get_all(), gc)) { |
2435 /* struct oscar_data *od = gc->proto_data; */ | 2451 /* struct oscar_data *od = gc->proto_data; */ |
2436 /* XXX - Take the buddy out of our buddy list */ | 2452 /* XXX - Take the buddy out of our buddy list */ |
2437 } | 2453 } |
2438 | 2454 |
2439 gaim_free_name_data(data); | 2455 oscar_free_name_data(data); |
2440 } | 2456 } |
2441 | 2457 |
2442 static void gaim_auth_sendrequest(GaimConnection *gc, const char *name) { | 2458 static void gaim_auth_sendrequest(GaimConnection *gc, const char *name) { |
2443 struct name_data *data = g_new(struct name_data, 1); | 2459 struct name_data *data = g_new(struct name_data, 1); |
2444 struct buddy *buddy; | 2460 struct buddy *buddy; |
2481 #else | 2497 #else |
2482 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); | 2498 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
2483 #endif | 2499 #endif |
2484 } | 2500 } |
2485 | 2501 |
2486 gaim_free_name_data(data); | 2502 oscar_free_name_data(data); |
2487 } | 2503 } |
2488 | 2504 |
2489 /* When other people ask you for authorization */ | 2505 /* When other people ask you for authorization */ |
2490 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { | 2506 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
2491 GaimConnection *gc = data->gc; | 2507 GaimConnection *gc = data->gc; |
2502 | 2518 |
2503 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | 2519 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { |
2504 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), | 2520 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
2505 NULL, _("No reason given."), TRUE, | 2521 NULL, _("No reason given."), TRUE, |
2506 _("OK"), G_CALLBACK(gaim_auth_dontgrant), | 2522 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
2507 _("Cancel"), G_CALLBACK(gaim_free_name_data), | 2523 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
2508 data); | 2524 data); |
2509 } | 2525 } |
2510 | 2526 |
2511 /* When someone sends you contacts */ | 2527 /* When someone sends you contacts */ |
2512 static void gaim_icq_contactadd(struct name_data *data) { | 2528 static void gaim_icq_contactadd(struct name_data *data) { |
2514 | 2530 |
2515 if (g_list_find(gaim_connections_get_all(), gc)) { | 2531 if (g_list_find(gaim_connections_get_all(), gc)) { |
2516 show_add_buddy(gc, data->name, NULL, data->nick); | 2532 show_add_buddy(gc, data->name, NULL, data->nick); |
2517 } | 2533 } |
2518 | 2534 |
2519 gaim_free_name_data(data); | 2535 oscar_free_name_data(data); |
2520 } | 2536 } |
2521 | 2537 |
2522 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t) { | 2538 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t) { |
2523 GaimConnection *gc = sess->aux_data; | 2539 GaimConnection *gc = sess->aux_data; |
2524 gchar **msg1, **msg2; | 2540 gchar **msg1, **msg2; |
2654 gaim_request_action(gc, NULL, message, | 2670 gaim_request_action(gc, NULL, message, |
2655 _("Do you want to add this contact " | 2671 _("Do you want to add this contact " |
2656 "to your Buddy List?"), | 2672 "to your Buddy List?"), |
2657 0, data, 2, | 2673 0, data, 2, |
2658 _("Add"), G_CALLBACK(gaim_icq_contactadd), | 2674 _("Add"), G_CALLBACK(gaim_icq_contactadd), |
2659 _("Decline"), G_CALLBACK(gaim_free_name_data)); | 2675 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
2660 g_free(message); | 2676 g_free(message); |
2661 } | 2677 } |
2662 g_strfreev(text); | 2678 g_strfreev(text); |
2663 } | 2679 } |
2664 } break; | 2680 } break; |
4998 data->nick = NULL; | 5014 data->nick = NULL; |
4999 | 5015 |
5000 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, | 5016 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
5001 0, data, | 5017 0, data, |
5002 G_CALLBACK(gaim_icq_contactadd), | 5018 G_CALLBACK(gaim_icq_contactadd), |
5003 G_CALLBACK(gaim_free_name_data)); | 5019 G_CALLBACK(oscar_free_name_data)); |
5004 | 5020 |
5005 g_free(dialog_msg); | 5021 g_free(dialog_msg); |
5006 g_free(nombre); | 5022 g_free(nombre); |
5007 | 5023 |
5008 return 1; | 5024 return 1; |
5351 char *caps = caps_string(bi->caps); | 5367 char *caps = caps_string(bi->caps); |
5352 tmp = yay; | 5368 tmp = yay; |
5353 yay = g_strconcat(tmp, _("<b>Capabilities:</b> "), caps, "\n", NULL); | 5369 yay = g_strconcat(tmp, _("<b>Capabilities:</b> "), caps, "\n", NULL); |
5354 free(tmp); | 5370 free(tmp); |
5355 } | 5371 } |
5372 | |
5373 if (bi->availablemsg) { | |
5374 tmp = yay; | |
5375 yay = g_strconcat(tmp, _("<b>Available:</b> "), bi->availablemsg, "\n", NULL); | |
5376 free(tmp); | |
5377 } | |
5356 } | 5378 } |
5357 } else { | 5379 } else { |
5358 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | 5380 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
5359 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) { | 5381 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) { |
5360 tmp = yay; | 5382 tmp = yay; |
5381 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | 5403 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { |
5382 if (isdigit(b->name[0])) | 5404 if (isdigit(b->name[0])) |
5383 ret = gaim_icq_status((b->uc & 0xffff0000) >> 16); | 5405 ret = gaim_icq_status((b->uc & 0xffff0000) >> 16); |
5384 else | 5406 else |
5385 ret = g_strdup(_("Away")); | 5407 ret = g_strdup(_("Away")); |
5386 } else if (!GAIM_BUDDY_IS_ONLINE(b)) { | 5408 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
5409 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, normalize(b->name)); | |
5410 if (bi->availablemsg) | |
5411 ret = g_strdup(bi->availablemsg); | |
5412 } else { | |
5387 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | 5413 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
5388 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | 5414 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) |
5389 ret = g_strdup(_("Not Authorized")); | 5415 ret = g_strdup(_("Not Authorized")); |
5390 else | 5416 else |
5391 ret = g_strdup(_("Offline")); | 5417 ret = g_strdup(_("Offline")); |