Mercurial > pidgin.yaz
comparison src/protocols/gg/gg.c @ 5603:ea09a005a10d
[gaim-migrate @ 6007]
this compiles, should work ok
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sat, 31 May 2003 15:06:17 +0000 |
parents | 7805a9a2c6ba |
children | 4fa8ca4f4259 |
comparison
equal
deleted
inserted
replaced
5602:67900446fab9 | 5603:ea09a005a10d |
---|---|
1 /* | 1 /* |
2 * gaim - Gadu-Gadu Protocol Plugin | 2 * gaim - Gadu-Gadu Protocol Plugin |
3 * $Id: gg.c 6001 2003-05-31 14:29:44Z lschiere $ | 3 * $Id: gg.c 6007 2003-05-31 15:06:17Z faceprint $ |
4 * | 4 * |
5 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> | 5 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License as published by | 8 * it under the terms of the GNU General Public License as published by |
54 #include "win32dep.h" | 54 #include "win32dep.h" |
55 #endif | 55 #endif |
56 | 56 |
57 #define USEROPT_NICK 0 | 57 #define USEROPT_NICK 0 |
58 | 58 |
59 #define GG_CONNECT_STEPS 5 | |
60 | |
59 #define AGG_BUF_LEN 1024 | 61 #define AGG_BUF_LEN 1024 |
60 | 62 |
61 #define AGG_GENDER_NONE -1 | 63 #define AGG_GENDER_NONE -1 |
62 | 64 |
63 #define AGG_PUBDIR_USERLIST_EXPORT_FORM "/appsvc/fmcontactsput.asp" | 65 #define AGG_PUBDIR_USERLIST_EXPORT_FORM "/appsvc/fmcontactsput.asp" |
176 default: | 178 default: |
177 g_snprintf(msg, sizeof(msg), _("Unknown Error Code.")); | 179 g_snprintf(msg, sizeof(msg), _("Unknown Error Code.")); |
178 break; | 180 break; |
179 } | 181 } |
180 | 182 |
181 hide_login_progress(gc, msg); | 183 gaim_connection_error(gc, msg); |
182 | 184 |
183 return msg; | 185 return msg; |
184 } | 186 } |
185 | 187 |
186 static void agg_set_away(GaimConnection *gc, char *state, char *msg) | 188 static void agg_set_away(GaimConnection *gc, char *state, char *msg) |
298 | 300 |
299 if (gd->sess->fd != source) | 301 if (gd->sess->fd != source) |
300 gd->sess->fd = source; | 302 gd->sess->fd = source; |
301 | 303 |
302 if (source == 0) { | 304 if (source == 0) { |
303 hide_login_progress(gc, _("Could not connect")); | 305 gaim_connection_error(gc, _("Could not connect")); |
304 signoff(gc); | |
305 return; | 306 return; |
306 } | 307 } |
307 | 308 |
308 if (!(e = gg_watch_fd(gd->sess))) { | 309 if (!(e = gg_watch_fd(gd->sess))) { |
309 debug_printf("main_callback: gg_watch_fd failed - CRITICAL!\n"); | 310 debug_printf("main_callback: gg_watch_fd failed - CRITICAL!\n"); |
310 hide_login_progress(gc, _("Unable to read socket")); | 311 gaim_connection_error(gc, _("Unable to read socket")); |
311 signoff(gc); | |
312 return; | 312 return; |
313 } | 313 } |
314 | 314 |
315 switch (e->type) { | 315 switch (e->type) { |
316 case GG_EVENT_NONE: | 316 case GG_EVENT_NONE: |
321 break; | 321 break; |
322 case GG_EVENT_CONN_FAILED: | 322 case GG_EVENT_CONN_FAILED: |
323 if (gc->inpa) | 323 if (gc->inpa) |
324 gaim_input_remove(gc->inpa); | 324 gaim_input_remove(gc->inpa); |
325 handle_errcode(gc, e->event.failure); | 325 handle_errcode(gc, e->event.failure); |
326 signoff(gc); | |
327 break; | 326 break; |
328 case GG_EVENT_MSG: | 327 case GG_EVENT_MSG: |
329 { | 328 { |
330 gchar *imsg; | 329 gchar *imsg; |
331 gchar user[20]; | 330 gchar user[20]; |
413 if (!g_slist_find(connections, gc)) { | 412 if (!g_slist_find(connections, gc)) { |
414 close(source); | 413 close(source); |
415 return; | 414 return; |
416 } | 415 } |
417 debug_printf("Found GG connection\n"); | 416 debug_printf("Found GG connection\n"); |
418 | 417 |
419 if (source == 0) { | 418 if (source == 0) { |
420 hide_login_progress(gc, _("Unable to connect.")); | 419 gaim_connection_error(gc, _("Unable to connect.")); |
421 signoff(gc); | |
422 return; | 420 return; |
423 } | 421 } |
424 | 422 |
425 gd->sess->fd = source; | 423 gd->sess->fd = source; |
426 | 424 |
431 debug_printf("Adding watch on fd\n"); | 429 debug_printf("Adding watch on fd\n"); |
432 } | 430 } |
433 debug_printf("Checking State.\n"); | 431 debug_printf("Checking State.\n"); |
434 switch (gd->sess->state) { | 432 switch (gd->sess->state) { |
435 case GG_STATE_READING_DATA: | 433 case GG_STATE_READING_DATA: |
436 set_login_progress(gc, 2, _("Reading data")); | 434 gaim_connection_update_progress(gc, _("Reading data"), 2, GG_CONNECT_STEPS); |
437 break; | 435 break; |
438 case GG_STATE_CONNECTING_GG: | 436 case GG_STATE_CONNECTING_GG: |
439 set_login_progress(gc, 3, _("Balancer handshake")); | 437 gaim_connection_update_progress(gc, _("Balancer handshake"), 3, GG_CONNECT_STEPS); |
440 break; | 438 break; |
441 case GG_STATE_READING_KEY: | 439 case GG_STATE_READING_KEY: |
442 set_login_progress(gc, 4, _("Reading server key")); | 440 gaim_connection_update_progress(gc, _("Reading server key"), 4, GG_CONNECT_STEPS); |
443 break; | 441 break; |
444 case GG_STATE_READING_REPLY: | 442 case GG_STATE_READING_REPLY: |
445 set_login_progress(gc, 5, _("Exchanging key hash")); | 443 gaim_connection_update_progress(gc, _("Exchanging key hash"), 5, GG_CONNECT_STEPS); |
446 break; | 444 break; |
447 default: | 445 default: |
448 debug_printf("No State found\n"); | 446 debug_printf("No State found\n"); |
449 break; | 447 break; |
450 } | 448 } |
451 debug_printf("gg_watch_fd\n"); | 449 debug_printf("gg_watch_fd\n"); |
452 if (!(e = gg_watch_fd(gd->sess))) { | 450 if (!(e = gg_watch_fd(gd->sess))) { |
453 debug_printf("login_callback: gg_watch_fd failed - CRITICAL!\n"); | 451 debug_printf("login_callback: gg_watch_fd failed - CRITICAL!\n"); |
454 hide_login_progress(gc, _("Critical error in GG library\n")); | 452 gaim_connection_error(gc, _("Critical error in GG library\n")); |
455 signoff(gc); | |
456 return; | 453 return; |
457 } | 454 } |
458 | 455 |
459 /* If we are GG_STATE_CONNECTING_GG then we still need to connect, as | 456 /* If we are GG_STATE_CONNECTING_GG then we still need to connect, as |
460 we could not use proxy_connect in libgg.c */ | 457 we could not use proxy_connect in libgg.c */ |
469 | 466 |
470 ip.s_addr = gd->sess->server_ip; | 467 ip.s_addr = gd->sess->server_ip; |
471 | 468 |
472 if (proxy_connect(gc->account, inet_ntoa(ip), gd->sess->port, login_callback, gc) < 0) { | 469 if (proxy_connect(gc->account, inet_ntoa(ip), gd->sess->port, login_callback, gc) < 0) { |
473 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), inet_ntoa(ip)); | 470 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), inet_ntoa(ip)); |
474 hide_login_progress(gc, buf); | 471 gaim_connection_error(gc, buf); |
475 signoff(gc); | |
476 return; | 472 return; |
477 } | 473 } |
478 break; | 474 break; |
479 } | 475 } |
480 case GG_STATE_READING_KEY: | 476 case GG_STATE_READING_KEY: |
503 break; | 499 break; |
504 case GG_EVENT_CONN_FAILED: | 500 case GG_EVENT_CONN_FAILED: |
505 gaim_input_remove(gc->inpa); | 501 gaim_input_remove(gc->inpa); |
506 gc->inpa = 0; | 502 gc->inpa = 0; |
507 handle_errcode(gc, e->event.failure); | 503 handle_errcode(gc, e->event.failure); |
508 signoff(gc); | |
509 break; | 504 break; |
510 default: | 505 default: |
511 debug_printf("no gg_event\n"); | 506 debug_printf("no gg_event\n"); |
512 break; | 507 break; |
513 } | 508 } |
517 | 512 |
518 static void agg_keepalive(GaimConnection *gc) | 513 static void agg_keepalive(GaimConnection *gc) |
519 { | 514 { |
520 struct agg_data *gd = (struct agg_data *)gc->proto_data; | 515 struct agg_data *gd = (struct agg_data *)gc->proto_data; |
521 if (gg_ping(gd->sess) < 0) { | 516 if (gg_ping(gd->sess) < 0) { |
522 hide_login_progress(gc, _("Unable to ping server")); | 517 gaim_connection_error(gc, _("Unable to ping server")); |
523 signoff(gc); | |
524 return; | 518 return; |
525 } | 519 } |
526 } | 520 } |
527 | 521 |
528 static void agg_login(GaimAccount *account) | 522 static void agg_login(GaimAccount *account) |
535 gc->checkbox = _("Send as message"); | 529 gc->checkbox = _("Send as message"); |
536 #endif | 530 #endif |
537 | 531 |
538 gd->sess = g_new0(struct gg_session, 1); | 532 gd->sess = g_new0(struct gg_session, 1); |
539 | 533 |
540 gaim_connection_set_display_name(account, gaim_account_get_string("nick")); | 534 gaim_connection_set_display_name(gc, gaim_account_get_string(account, "nick", "")); |
541 | 535 |
542 set_login_progress(gc, 1, _("Looking up GG server")); | 536 gaim_connection_update_progress(gc, _("Looking up GG server"), 1, GG_CONNECT_STEPS); |
543 | 537 |
544 if (invalid_uin(account->username)) { | 538 if (invalid_uin(account->username)) { |
545 hide_login_progress(gc, _("Invalid Gadu-Gadu UIN specified")); | 539 gaim_connection_error(gc, _("Invalid Gadu-Gadu UIN specified")); |
546 signoff(gc); | |
547 return; | 540 return; |
548 } | 541 } |
549 | 542 |
550 gc->inpa = 0; | 543 gc->inpa = 0; |
551 | 544 |
565 gd->sess->state = GG_STATE_CONNECTING; | 558 gd->sess->state = GG_STATE_CONNECTING; |
566 gd->sess->check = GG_CHECK_WRITE; | 559 gd->sess->check = GG_CHECK_WRITE; |
567 gd->sess->async = 1; | 560 gd->sess->async = 1; |
568 if (proxy_connect(account, GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc) < 0) { | 561 if (proxy_connect(account, GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc) < 0) { |
569 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), GG_APPMSG_HOST); | 562 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), GG_APPMSG_HOST); |
570 hide_login_progress(gc, buf); | 563 gaim_connection_error(gc, buf); |
571 signoff(gc); | |
572 return; | 564 return; |
573 } | 565 } |
574 } | 566 } |
575 | 567 |
576 static void agg_close(GaimConnection *gc) | 568 static void agg_close(GaimConnection *gc) |
989 } | 981 } |
990 | 982 |
991 static void import_buddies_server(GaimConnection *gc) | 983 static void import_buddies_server(GaimConnection *gc) |
992 { | 984 { |
993 struct agg_http *hi = g_new0(struct agg_http, 1); | 985 struct agg_http *hi = g_new0(struct agg_http, 1); |
994 gchar *u = gg_urlencode(gc->username); | 986 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
995 gchar *p = gg_urlencode(gc->password); | 987 gchar *p = gg_urlencode(gaim_account_get_password(gc->account)); |
996 | 988 |
997 hi->gc = gc; | 989 hi->gc = gc; |
998 hi->type = AGG_HTTP_USERLIST_IMPORT; | 990 hi->type = AGG_HTTP_USERLIST_IMPORT; |
999 hi->form = AGG_PUBDIR_USERLIST_IMPORT_FORM; | 991 hi->form = AGG_PUBDIR_USERLIST_IMPORT_FORM; |
1000 hi->host = GG_PUBDIR_HOST; | 992 hi->host = GG_PUBDIR_HOST; |
1016 | 1008 |
1017 static void export_buddies_server(GaimConnection *gc) | 1009 static void export_buddies_server(GaimConnection *gc) |
1018 { | 1010 { |
1019 struct agg_http *he = g_new0(struct agg_http, 1); | 1011 struct agg_http *he = g_new0(struct agg_http, 1); |
1020 gchar *ptr; | 1012 gchar *ptr; |
1021 gchar *u = gg_urlencode(gc->username); | 1013 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
1022 gchar *p = gg_urlencode(gc->password); | 1014 gchar *p = gg_urlencode(gaim_account_get_password(gc->account)); |
1023 | 1015 |
1024 GaimBlistNode *gnode, *bnode; | 1016 GaimBlistNode *gnode, *bnode; |
1025 | 1017 |
1026 he->gc = gc; | 1018 he->gc = gc; |
1027 he->type = AGG_HTTP_USERLIST_EXPORT; | 1019 he->type = AGG_HTTP_USERLIST_EXPORT; |
1085 } | 1077 } |
1086 | 1078 |
1087 static void delete_buddies_server(GaimConnection *gc) | 1079 static void delete_buddies_server(GaimConnection *gc) |
1088 { | 1080 { |
1089 struct agg_http *he = g_new0(struct agg_http, 1); | 1081 struct agg_http *he = g_new0(struct agg_http, 1); |
1090 gchar *u = gg_urlencode(gc->username); | 1082 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
1091 gchar *p = gg_urlencode(gc->password); | 1083 gchar *p = gg_urlencode(gaim_account_get_password(gc->account)); |
1092 | 1084 |
1093 he->gc = gc; | 1085 he->gc = gc; |
1094 he->type = AGG_HTTP_USERLIST_DELETE; | 1086 he->type = AGG_HTTP_USERLIST_DELETE; |
1095 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; | 1087 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; |
1096 he->host = GG_PUBDIR_HOST; | 1088 he->host = GG_PUBDIR_HOST; |
1158 } | 1150 } |
1159 | 1151 |
1160 static void agg_change_passwd(GaimConnection *gc, const char *old, const char *new) | 1152 static void agg_change_passwd(GaimConnection *gc, const char *old, const char *new) |
1161 { | 1153 { |
1162 struct agg_http *hpass = g_new0(struct agg_http, 1); | 1154 struct agg_http *hpass = g_new0(struct agg_http, 1); |
1163 gchar *u = gg_urlencode(gc->username); | 1155 gchar *u = gg_urlencode(gaim_account_get_username(gc->account)); |
1164 gchar *p = gg_urlencode(gc->password); | 1156 gchar *p = gg_urlencode(gaim_account_get_password(gc->account)); |
1165 gchar *enew = gg_urlencode(new); | 1157 gchar *enew = gg_urlencode(new); |
1166 gchar *eold = gg_urlencode(old); | 1158 gchar *eold = gg_urlencode(old); |
1167 | 1159 |
1168 hpass->gc = gc; | 1160 hpass->gc = gc; |
1169 hpass->type = AGG_HTTP_PASSWORD_CHANGE; | 1161 hpass->type = AGG_HTTP_PASSWORD_CHANGE; |