comparison src/protocols/gg/gg.c @ 3427:8fa61405af2b

[gaim-migrate @ 3453] Who never commits anything *now*, Etan? I changed most of the error message text around. If you think any of it should be different, just let me know, or send a patch. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sun, 25 Aug 2002 10:51:24 +0000
parents afa68a8feee2
children 7a3f16a375a5
comparison
equal deleted inserted replaced
3426:ccbcc11a68c2 3427:8fa61405af2b
1 /* 1 /*
2 * gaim - Gadu-Gadu Protocol Plugin 2 * gaim - Gadu-Gadu Protocol Plugin
3 * $Id: gg.c 3358 2002-06-28 01:47:12Z jseymour $ 3 * $Id: gg.c 3453 2002-08-25 10:51:24Z seanegan $
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
589 { 589 {
590 struct agg_data *gd = (struct agg_data *)gc->proto_data; 590 struct agg_data *gd = (struct agg_data *)gc->proto_data;
591 gchar *imsg; 591 gchar *imsg;
592 592
593 if (invalid_uin(who)) { 593 if (invalid_uin(who)) {
594 do_error_dialog(_("You are trying to send a message to an invalid Gadu-Gadu UIN."), 594 do_error_dialog(_("You are trying to send a message to an invalid Gadu-Gadu UIN."), NULL,
595 _("Gadu-Gadu Error")); 595 GAIM_ERROR);
596 return -1; 596 return -1;
597 } 597 }
598 598
599 if (strlen(msg) > 0) { 599 if (strlen(msg) > 0) {
600 imsg = charset_convert(msg, find_local_charset(), "CP1250"); 600 imsg = charset_convert(msg, find_local_charset(), "CP1250");
652 char *ptr; 652 char *ptr;
653 int i, j; 653 int i, j;
654 654
655 if ((ptr = strstr(webdata, "query_results:")) == NULL || (ptr = strchr(ptr, '\n')) == NULL) { 655 if ((ptr = strstr(webdata, "query_results:")) == NULL || (ptr = strchr(ptr, '\n')) == NULL) {
656 debug_printf("search_callback: pubdir result [%s]\n", webdata); 656 debug_printf("search_callback: pubdir result [%s]\n", webdata);
657 do_error_dialog(_("Couldn't get search results"), _("Gadu-Gadu Error")); 657 do_error_dialog(_("Couldn't get search results"), NULL, GAIM_ERROR);
658 return; 658 return;
659 } 659 }
660 ptr++; 660 ptr++;
661 661
662 buf = g_strconcat("<B>", _("Gadu-Gadu Search Engine"), "</B><BR>\n", NULL); 662 buf = g_strconcat("<B>", _("Gadu-Gadu Search Engine"), "</B><BR>\n", NULL);
756 { 756 {
757 gchar *ptr; 757 gchar *ptr;
758 gchar **users_tbl; 758 gchar **users_tbl;
759 int i; 759 int i;
760 if (strstr(webdata, "no_data:")) { 760 if (strstr(webdata, "no_data:")) {
761 do_error_dialog(_("There is no Buddy List stored on server. Sorry!"), 761 do_error_dialog(_("There is no Buddy List stored on the Gadu-Gadu server."), NULL, GAIM_ERROR);
762 _("Gadu-Gadu Error"));
763 return; 762 return;
764 } 763 }
765 764
766 if ((ptr = strstr(webdata, "get_results:")) == NULL || (ptr = strchr(ptr, ':')) == NULL) { 765 if ((ptr = strstr(webdata, "get_results:")) == NULL || (ptr = strchr(ptr, ':')) == NULL) {
767 debug_printf("import_buddies_server_results: import buddies result [%s]\n", webdata); 766 debug_printf("import_buddies_server_results: import buddies result [%s]\n", webdata);
768 do_error_dialog(_("Couldn't Import Buddies List from Server"), _("Gadu-Gadu Error")); 767 do_error_dialog(_("Couldn't Import Buddies List from Server"), NULL, GAIM_ERROR);
769 return; 768 return;
770 } 769 }
771 ptr++; 770 ptr++;
772 771
773 users_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES); 772 users_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES);
810 } 809 }
811 810
812 static void export_buddies_server_results(struct gaim_connection *gc, gchar *webdata) 811 static void export_buddies_server_results(struct gaim_connection *gc, gchar *webdata)
813 { 812 {
814 if (strstr(webdata, "put_success:")) { 813 if (strstr(webdata, "put_success:")) {
815 do_error_dialog(_("Buddy List successfully transferred to server"), 814 do_error_dialog(_("Buddy List successfully transferred to Gadu-Gadu server"), NULL, GAIM_INFO);
816 _("Gadu-Gadu Information"));
817 return; 815 return;
818 } 816 }
819 817
820 debug_printf("export_buddies_server_results: webdata [%s]\n", webdata); 818 debug_printf("export_buddies_server_results: webdata [%s]\n", webdata);
821 do_error_dialog(_("Couldn't transfer Buddy List to server"), _("Gadu-Gadu Error")); 819 do_error_dialog(_("Couldn't transfer Buddy List to Gadu-Gadu server"), NULL, GAIM_ERROR);
822 } 820 }
823 821
824 static void delete_buddies_server_results(struct gaim_connection *gc, gchar *webdata) 822 static void delete_buddies_server_results(struct gaim_connection *gc, gchar *webdata)
825 { 823 {
826 if (strstr(webdata, "put_success:")) { 824 if (strstr(webdata, "put_success:")) {
827 do_error_dialog(_("Buddy List sucessfully deleted from server"), 825 do_error_dialog(_("Buddy List sucessfully deleted from Gadu-Gadu server"), NULL, GAIM_INFO);
828 _("Gadu-Gadu Information"));
829 return; 826 return;
830 } 827 }
831 828
832 debug_printf("delete_buddies_server_results: webdata [%s]\n", webdata); 829 debug_printf("delete_buddies_server_results: webdata [%s]\n", webdata);
833 do_error_dialog(_("Couldn't delete Buddy List from server"), _("Gadu-Gadu Error")); 830 do_error_dialog(_("Couldn't delete Buddy List from Gadu-Gadu server"), NULL, GAIM_ERROR);
834 } 831 }
835 832
836 static void password_change_server_results(struct gaim_connection *gc, gchar *webdata) 833 static void password_change_server_results(struct gaim_connection *gc, gchar *webdata)
837 { 834 {
838 if (strstr(webdata, "reg_success:")) { 835 if (strstr(webdata, "reg_success:")) {
839 do_error_dialog(_("Password changed successfully"), 836 do_error_dialog(_("Password changed successfully"), NULL, GAIM_INFO);
840 _("Gadu-Gadu Information"));
841 return; 837 return;
842 } 838 }
843 839
844 debug_printf("delete_buddies_server_results: webdata [%s]\n", webdata); 840 debug_printf("delete_buddies_server_results: webdata [%s]\n", webdata);
845 do_error_dialog(_("Password couldn't be changed"), _("Gadu-Gadu Error")); 841 do_error_dialog(_("Password couldn't be changed"), NULL, GAIM_ERROR);
846 } 842 }
847 843
848 static void http_results(gpointer data, gint source, GaimInputCondition cond) 844 static void http_results(gpointer data, gint source, GaimInputCondition cond)
849 { 845 {
850 struct agg_http *hdata = data; 846 struct agg_http *hdata = data;
951 947
952 if (write(source, buf, strlen(buf)) < strlen(buf)) { 948 if (write(source, buf, strlen(buf)) < strlen(buf)) {
953 g_free(buf); 949 g_free(buf);
954 g_free(hdata); 950 g_free(hdata);
955 close(source); 951 close(source);
956 do_error_dialog(_("Couldn't send http request"), _("Gadu-Gadu Error")); 952 do_error_dialog(_("Error communicating with Gadu-Gadu server"),
953 _("Gaim was unable to complete your request due to a problem "
954 "communicating to the Gadu-Gadu HTTP server. Please try again "
955 "later."), GAIM_ERROR);
957 return; 956 return;
958 } 957 }
959 958
960 g_free(buf); 959 g_free(buf);
961 960
963 } 962 }
964 963
965 static void import_buddies_server(struct gaim_connection *gc) 964 static void import_buddies_server(struct gaim_connection *gc)
966 { 965 {
967 struct agg_http *hi = g_new0(struct agg_http, 1); 966 struct agg_http *hi = g_new0(struct agg_http, 1);
968 static char msg[AGG_BUF_LEN];
969 gchar *u = gg_urlencode(gc->username); 967 gchar *u = gg_urlencode(gc->username);
970 gchar *p = gg_urlencode(gc->password); 968 gchar *p = gg_urlencode(gc->password);
971 969
972 hi->gc = gc; 970 hi->gc = gc;
973 hi->type = AGG_HTTP_USERLIST_IMPORT; 971 hi->type = AGG_HTTP_USERLIST_IMPORT;
977 975
978 g_free(u); 976 g_free(u);
979 g_free(p); 977 g_free(p);
980 978
981 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, hi) < 0) { 979 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, hi) < 0) {
982 g_snprintf(msg, sizeof(msg), _("Buddies List import from Server failed (%s)"), 980 do_error_dialog(_("Unable to import Gadu-Gadu buddy list"),
983 GG_PUBDIR_HOST); 981 _("Gaim was unable to connect to the Gadu-Gadu buddy list "
984 do_error_dialog(msg, _("Gadu-Gadu Error")); 982 "server. Please try again later."), GAIM_ERROR);
985 g_free(hi->request); 983 g_free(hi->request);
986 g_free(hi); 984 g_free(hi);
987 return; 985 return;
988 } 986 }
989 } 987 }
990 988
991 static void export_buddies_server(struct gaim_connection *gc) 989 static void export_buddies_server(struct gaim_connection *gc)
992 { 990 {
993 struct agg_http *he = g_new0(struct agg_http, 1); 991 struct agg_http *he = g_new0(struct agg_http, 1);
994 static char msg[AGG_BUF_LEN];
995 gchar *ptr; 992 gchar *ptr;
996 gchar *u = gg_urlencode(gc->username); 993 gchar *u = gg_urlencode(gc->username);
997 gchar *p = gg_urlencode(gc->password); 994 gchar *p = gg_urlencode(gc->password);
998 995
999 GSList *gr = gc->groups; 996 GSList *gr = gc->groups;
1036 } 1033 }
1037 gr = g_slist_next(gr); 1034 gr = g_slist_next(gr);
1038 } 1035 }
1039 1036
1040 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { 1037 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) {
1041 g_snprintf(msg, sizeof(msg), _("Buddies List export to Server failed (%s)"), 1038 do_error_dialog(_("Couldn't export buddy list"),
1042 GG_PUBDIR_HOST); 1039 _("Gaim was unable to connect to the buddy list server. "
1043 do_error_dialog(msg, _("Gadu-Gadu Error")); 1040 "Please try again later."), GAIM_ERROR);
1044 g_free(he->request); 1041 g_free(he->request);
1045 g_free(he); 1042 g_free(he);
1046 return; 1043 return;
1047 } 1044 }
1048 } 1045 }
1049 1046
1050 static void delete_buddies_server(struct gaim_connection *gc) 1047 static void delete_buddies_server(struct gaim_connection *gc)
1051 { 1048 {
1052 struct agg_http *he = g_new0(struct agg_http, 1); 1049 struct agg_http *he = g_new0(struct agg_http, 1);
1053 static char msg[AGG_BUF_LEN];
1054 gchar *u = gg_urlencode(gc->username); 1050 gchar *u = gg_urlencode(gc->username);
1055 gchar *p = gg_urlencode(gc->password); 1051 gchar *p = gg_urlencode(gc->password);
1056 1052
1057 he->gc = gc; 1053 he->gc = gc;
1058 he->type = AGG_HTTP_USERLIST_DELETE; 1054 he->type = AGG_HTTP_USERLIST_DELETE;
1059 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM; 1055 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM;
1060 he->host = GG_PUBDIR_HOST; 1056 he->host = GG_PUBDIR_HOST;
1061 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Delete=1", u, p); 1057 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Delete=1", u, p);
1062 1058
1063 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) { 1059 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) {
1064 g_snprintf(msg, sizeof(msg), _("Deletion of Buddies List from Server failed (%s)"), 1060 do_error_dialog(_("Unable to delete Gadu-Gadu buddy list"),
1065 GG_PUBDIR_HOST); 1061 _("Gaim was unable to connect to the buddy list server. "
1066 do_error_dialog(msg, _("Gadu-Gadu Error")); 1062 "Please try again later."), GAIM_ERROR);
1067 g_free(he->request); 1063 g_free(he->request);
1068 g_free(he); 1064 g_free(he);
1069 return; 1065 return;
1070 } 1066 }
1071 } 1067 }
1073 static void agg_dir_search(struct gaim_connection *gc, char *first, char *middle, 1069 static void agg_dir_search(struct gaim_connection *gc, char *first, char *middle,
1074 char *last, char *maiden, char *city, char *state, 1070 char *last, char *maiden, char *city, char *state,
1075 char *country, char *email) 1071 char *country, char *email)
1076 { 1072 {
1077 struct agg_http *srch = g_new0(struct agg_http, 1); 1073 struct agg_http *srch = g_new0(struct agg_http, 1);
1078 static char msg[AGG_BUF_LEN];
1079
1080 srch->gc = gc; 1074 srch->gc = gc;
1081 srch->type = AGG_HTTP_SEARCH; 1075 srch->type = AGG_HTTP_SEARCH;
1082 srch->form = AGG_PUBDIR_SEARCH_FORM; 1076 srch->form = AGG_PUBDIR_SEARCH_FORM;
1083 srch->host = GG_PUBDIR_HOST; 1077 srch->host = GG_PUBDIR_HOST;
1084 1078
1109 g_free(enew_last); 1103 g_free(enew_last);
1110 g_free(enew_city); 1104 g_free(enew_city);
1111 } 1105 }
1112 1106
1113 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { 1107 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) {
1114 g_snprintf(msg, sizeof(msg), _("Connect to search service failed (%s)"), 1108 do_error_dialog(_("Unable to access directory"),
1115 GG_PUBDIR_HOST); 1109 _("Gaim was unable to search the Directory because it "
1116 do_error_dialog(msg, _("Gadu-Gadu Error")); 1110 "was unable to connect to the directory server. Please try"
1111 "again later."), GAIM_ERROR);
1117 g_free(srch->request); 1112 g_free(srch->request);
1118 g_free(srch); 1113 g_free(srch);
1119 return; 1114 return;
1120 } 1115 }
1121 } 1116 }
1122 1117
1123 static void agg_change_passwd(struct gaim_connection *gc, char *old, char *new) 1118 static void agg_change_passwd(struct gaim_connection *gc, char *old, char *new)
1124 { 1119 {
1125 struct agg_http *hpass = g_new0(struct agg_http, 1); 1120 struct agg_http *hpass = g_new0(struct agg_http, 1);
1126 static char msg[AGG_BUF_LEN];
1127 gchar *u = gg_urlencode(gc->username); 1121 gchar *u = gg_urlencode(gc->username);
1128 gchar *p = gg_urlencode(gc->password); 1122 gchar *p = gg_urlencode(gc->password);
1129 gchar *enew = gg_urlencode(new); 1123 gchar *enew = gg_urlencode(new);
1130 gchar *eold = gg_urlencode(old); 1124 gchar *eold = gg_urlencode(old);
1131 1125
1142 g_free(p); 1136 g_free(p);
1143 g_free(enew); 1137 g_free(enew);
1144 g_free(eold); 1138 g_free(eold);
1145 1139
1146 if (proxy_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, http_req_callback, hpass) < 0) { 1140 if (proxy_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, http_req_callback, hpass) < 0) {
1147 g_snprintf(msg, sizeof(msg), _("Changing Password failed (%s)"), 1141 do_error_dialog(_("Unable to change Gadu-Gadu password"),
1148 GG_REGISTER_HOST); 1142 _("Gaim was unable to change your password due to an error connecting "
1149 do_error_dialog(msg, _("Gadu-Gadu Error")); 1143 "to the Gadu-Gadu server. Please try again later."), GAIM_ERROR);
1150 g_free(hpass->request); 1144 g_free(hpass->request);
1151 g_free(hpass); 1145 g_free(hpass);
1152 return; 1146 return;
1153 } 1147 }
1154 } 1148 }
1184 } 1178 }
1185 1179
1186 static void agg_get_info(struct gaim_connection *gc, char *who) 1180 static void agg_get_info(struct gaim_connection *gc, char *who)
1187 { 1181 {
1188 struct agg_http *srch = g_new0(struct agg_http, 1); 1182 struct agg_http *srch = g_new0(struct agg_http, 1);
1189 static char msg[AGG_BUF_LEN];
1190
1191 srch->gc = gc; 1183 srch->gc = gc;
1192 srch->type = AGG_HTTP_SEARCH; 1184 srch->type = AGG_HTTP_SEARCH;
1193 srch->form = AGG_PUBDIR_SEARCH_FORM; 1185 srch->form = AGG_PUBDIR_SEARCH_FORM;
1194 srch->host = GG_PUBDIR_HOST; 1186 srch->host = GG_PUBDIR_HOST;
1195 1187
1207 g_free(enew_who); 1199 g_free(enew_who);
1208 } else 1200 } else
1209 srch->request = g_strdup_printf("Mode=3&UserId=%s", who); 1201 srch->request = g_strdup_printf("Mode=3&UserId=%s", who);
1210 1202
1211 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) { 1203 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) {
1212 g_snprintf(msg, sizeof(msg), _("Connect to search service failed (%s)"), 1204 do_error_dialog(_("Unable to access user profile."),
1213 GG_PUBDIR_HOST); 1205 _("Gaim was unable to access this users profile due to an error "
1214 do_error_dialog(msg, _("Gadu-Gadu Error")); 1206 "connecting to the directory server. Please try again later."), GAIM_ERROR);
1215 g_free(srch->request); 1207 g_free(srch->request);
1216 g_free(srch); 1208 g_free(srch);
1217 return; 1209 return;
1218 } 1210 }
1219 } 1211 }