annotate src/protocols/gg/gg.c @ 2831:cf50045c0167

[gaim-migrate @ 2844] i love this. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 02 Dec 2001 07:49:27 +0000
parents 1ffac7cf4e94
children d8e67ff8022f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim - Gadu-Gadu Protocol Plugin
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
3 * $Id: gg.c 2819 2001-11-27 22:54:32Z warmenhoven $
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 *
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
5 * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * (at your option) any later version.
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * GNU General Public License for more details.
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 *
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2518
diff changeset
23 #ifdef HAVE_CONFIG_H
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #include <config.h>
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2518
diff changeset
25 #endif
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include <netdb.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include <unistd.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <errno.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <netinet/in.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <arpa/inet.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include <fcntl.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #include <string.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include <stdlib.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include <stdio.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include <time.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include <sys/socket.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 #include <sys/stat.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #include <ctype.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #ifdef HAVE_LANGINFO_CODESET
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 #include <langinfo.h>
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 #endif
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 #ifdef HAVE_ICONV
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #include <iconv.h>
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2518
diff changeset
45 #include "iconv_string.h"
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #endif
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 /* Library from EKG (Eksperymentalny Klient Gadu-Gadu) */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #include "libgg.h"
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #include "multi.h"
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 #include "prpl.h"
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 #include "gaim.h"
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 #include "proxy.h"
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 #include "pixmaps/gg_suncloud.xpm"
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 #include "pixmaps/gg_sunred.xpm"
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 #include "pixmaps/gg_sunwhitered.xpm"
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 #include "pixmaps/gg_sunyellow.xpm"
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 #define USEROPT_NICK 0
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 #define AGG_BUF_LEN 1024
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 #define AGG_GENDER_NONE -1
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
65 #define AGG_PUBDIR_USERLIST_EXPORT_FORM "/appsvc/fmcontactsput.asp"
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
66 #define AGG_PUBDIR_USERLIST_IMPORT_FORM "/appsvc/fmcontactsget.asp"
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
67 #define AGG_PUBDIR_SEARCH_FORM "/appsvc/fmpubquery2.asp"
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 #define AGG_PUBDIR_MAX_ENTRIES 200
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 #define AGG_STATUS_AVAIL _("Available")
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 #define AGG_STATUS_AVAIL_FRIENDS _("Available for friends only")
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 #define AGG_STATUS_BUSY _("Away")
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 #define AGG_STATUS_BUSY_FRIENDS _("Away for friends only")
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 #define AGG_STATUS_INVISIBLE _("Invisible")
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 #define AGG_STATUS_INVISIBLE_FRIENDS _("Invisible for friends only")
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 #define AGG_STATUS_NOT_AVAIL _("Unavailable")
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
78 #define AGG_HTTP_NONE 0
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
79 #define AGG_HTTP_SEARCH 1
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
80 #define AGG_HTTP_USERLIST_IMPORT 2
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
81 #define AGG_HTTP_USERLIST_EXPORT 3
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
82 #define AGG_HTTP_USERLIST_DELETE 4
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
83
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2423
diff changeset
84 #define UC_NORMAL 2
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2423
diff changeset
85
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 struct agg_data {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 struct gg_session *sess;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 };
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
90 struct agg_http {
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 struct gaim_connection *gc;
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
92 gchar *request;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
93 gchar *form;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
94 gchar *host;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 int inpa;
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
96 int type;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 };
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 static char *agg_name()
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 return "Gadu-Gadu";
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 static gchar *charset_convert(const gchar *locstr, char *encsrc, char *encdst)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 {
2563
29d09f9ce85f [gaim-migrate @ 2576]
Rob Flynn <gaim@robflynn.com>
parents: 2542
diff changeset
106 #ifdef HAVE_ICONV
2542
221e1c8e2410 [gaim-migrate @ 2555]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
107 gchar *result = NULL;
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
108 if (iconv_string(encdst, encsrc, locstr, locstr + strlen(locstr) + 1, &result, NULL) >= 0)
2542
221e1c8e2410 [gaim-migrate @ 2555]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
109 return result;
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2518
diff changeset
110 #endif
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 return g_strdup(locstr);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 static gboolean invalid_uin(char *uin)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 unsigned long int res = strtol(uin, (char **)NULL, 10);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 if (res == LONG_MIN || res == LONG_MAX || res == 0)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 return TRUE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 return FALSE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 static gint args_compare(gconstpointer a, gconstpointer b)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 gchar *arg_a = (gchar *)a;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 gchar *arg_b = (gchar *)b;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 return g_strcasecmp(arg_a, arg_b);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 static gboolean allowed_uin(struct gaim_connection *gc, char *uin)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 switch (gc->permdeny) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 case 1:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 /* permit all, deny none */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 return TRUE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 case 2:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 /* deny all, permit none. */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 return FALSE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 case 3:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 /* permit some. */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 if (g_slist_find_custom(gc->permit, uin, args_compare))
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 return TRUE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 return FALSE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 case 4:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 /* deny some. */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 if (g_slist_find_custom(gc->deny, uin, args_compare))
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 return FALSE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 return TRUE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 default:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 return TRUE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 static gchar *find_local_charset(void)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 gchar *gg_localenc = g_getenv("GG_CHARSET");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 if (gg_localenc == NULL) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 #ifdef HAVE_LANGINFO_CODESET
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 gg_localenc = nl_langinfo(CODESET);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 #else
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 gg_localenc = "US-ASCII";
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 #endif
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 return gg_localenc;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 static char *handle_errcode(int errcode, gboolean show)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 static char msg[AGG_BUF_LEN];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 switch (errcode) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 case GG_FAILURE_RESOLVING:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 g_snprintf(msg, sizeof(msg), _("Unable to resolve hostname."));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 case GG_FAILURE_CONNECTING:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 g_snprintf(msg, sizeof(msg), _("Unable to connect to server."));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 case GG_FAILURE_INVALID:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 g_snprintf(msg, sizeof(msg), _("Invalid response from server."));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 case GG_FAILURE_READING:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 g_snprintf(msg, sizeof(msg), _("Error while reading from socket."));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 case GG_FAILURE_WRITING:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 g_snprintf(msg, sizeof(msg), _("Error while writting to socket."));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 case GG_FAILURE_PASSWORD:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 g_snprintf(msg, sizeof(msg), _("Authentification failed."));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 default:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 g_snprintf(msg, sizeof(msg), _("Unknown Error Code."));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 if (show)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 do_error_dialog(msg, _("Gadu-Gadu Error"));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 return msg;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 static gchar *encode_postdata(const gchar *data)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 gchar *p = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 int i, j = 0;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 for (i = 0; i < strlen(data); i++) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 /* locale insensitive, doesn't reflect RFC (1738 section 2.2, 1866 section 8.2.1) */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 if ((data[i] >= 'a' && data[i] <= 'z')
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 || (data[i] >= 'A' && data[i] <= 'Z')
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 || (data[i] >= '0' && data[i] <= '9')
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
216 || data[i] == '=' || data[i] == '&') {
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 p = g_realloc(p, j + 1);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 p[j] = data[i];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 j++;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 } else {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 p = g_realloc(p, j + 4); /* remember, sprintf appends a '\0' */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 sprintf(p + j, "%%%02x", (unsigned char)data[i]);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 j += 3;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 p = g_realloc(p, j + 1);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 p[j] = '\0';
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 if (p && strlen(p))
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230 return p;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 else
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 return g_strdup(data);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 static void agg_set_away(struct gaim_connection *gc, char *state, char *msg)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 struct agg_data *gd = (struct agg_data *)gc->proto_data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 if (gc->away)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 gc->away = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 if (!g_strcasecmp(state, AGG_STATUS_AVAIL))
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 gg_change_status(gd->sess, GG_STATUS_AVAIL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 else if (!g_strcasecmp(state, AGG_STATUS_AVAIL_FRIENDS))
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 gg_change_status(gd->sess, GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 else if (!g_strcasecmp(state, AGG_STATUS_BUSY)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 gg_change_status(gd->sess, GG_STATUS_BUSY);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 gc->away = "";
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 } else if (!g_strcasecmp(state, AGG_STATUS_BUSY_FRIENDS)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 gg_change_status(gd->sess, GG_STATUS_BUSY | GG_STATUS_FRIENDS_MASK);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 gc->away = "";
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 } else if (!g_strcasecmp(state, AGG_STATUS_INVISIBLE)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 gg_change_status(gd->sess, GG_STATUS_INVISIBLE);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 gc->away = "";
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 } else if (!g_strcasecmp(state, AGG_STATUS_INVISIBLE_FRIENDS)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 gg_change_status(gd->sess, GG_STATUS_INVISIBLE | GG_STATUS_FRIENDS_MASK);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 gc->away = "";
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 } else if (!g_strcasecmp(state, AGG_STATUS_NOT_AVAIL)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 gg_change_status(gd->sess, GG_STATUS_NOT_AVAIL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 gc->away = "";
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 } else if (!g_strcasecmp(state, GAIM_AWAY_CUSTOM)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 if (msg) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 gg_change_status(gd->sess, GG_STATUS_BUSY);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 gc->away = "";
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 } else
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 gg_change_status(gd->sess, GG_STATUS_AVAIL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 static gchar *get_away_text(int uc)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 if (uc == UC_UNAVAILABLE)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 return AGG_STATUS_NOT_AVAIL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 uc = uc >> 5;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 switch (uc) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 case GG_STATUS_AVAIL:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 default:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 return AGG_STATUS_AVAIL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 case GG_STATUS_AVAIL | GG_STATUS_FRIENDS_MASK:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 return AGG_STATUS_AVAIL_FRIENDS;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 case GG_STATUS_BUSY:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 return AGG_STATUS_BUSY;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 case GG_STATUS_BUSY | GG_STATUS_FRIENDS_MASK:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 return AGG_STATUS_BUSY_FRIENDS;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 case GG_STATUS_INVISIBLE:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 return AGG_STATUS_INVISIBLE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 case GG_STATUS_INVISIBLE | GG_STATUS_FRIENDS_MASK:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 return AGG_STATUS_INVISIBLE_FRIENDS;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 case GG_STATUS_NOT_AVAIL:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 return AGG_STATUS_NOT_AVAIL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2423
diff changeset
294 static GList *agg_away_states(struct gaim_connection *gc)
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 GList *m = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 m = g_list_append(m, AGG_STATUS_AVAIL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 m = g_list_append(m, AGG_STATUS_BUSY);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 m = g_list_append(m, AGG_STATUS_INVISIBLE);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 m = g_list_append(m, AGG_STATUS_AVAIL_FRIENDS);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 m = g_list_append(m, AGG_STATUS_BUSY_FRIENDS);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 m = g_list_append(m, AGG_STATUS_INVISIBLE_FRIENDS);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 m = g_list_append(m, AGG_STATUS_NOT_AVAIL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 return m;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 /* Enhance these functions, more options and such stuff */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 static GList *agg_buddy_menu(struct gaim_connection *gc, char *who)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 GList *m = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 struct proto_buddy_menu *pbm;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 struct buddy *b = find_buddy(gc, who);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 static char buf[AGG_BUF_LEN];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 if (!b) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 return m;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 pbm = g_new0(struct proto_buddy_menu, 1);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 g_snprintf(buf, sizeof(buf), _("Status: %s"), get_away_text(b->uc));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 pbm->label = buf;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 pbm->callback = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 pbm->gc = gc;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 m = g_list_append(m, pbm);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 return m;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 static GList *agg_user_opts()
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 GList *m = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 struct proto_user_opt *puo;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 puo = g_new0(struct proto_user_opt, 1);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 puo->label = _("Nick:");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 puo->def = _("Gadu-Gadu User");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 puo->pos = USEROPT_NICK;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 m = g_list_append(m, puo);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 return m;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 static void main_callback(gpointer data, gint source, GaimInputCondition cond)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 struct gaim_connection *gc = data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 struct agg_data *gd = gc->proto_data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 struct gg_event *e;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 debug_printf("main_callback enter: begin\n");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 if (gd->sess->fd != source)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 gd->sess->fd = source;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 if (source == -1) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 if (!(e = gg_watch_fd(gd->sess))) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 debug_printf("main_callback: gg_watch_fd failed - CRITICAL!\n");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 switch (e->type) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 case GG_EVENT_NONE:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 /* do nothing */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 case GG_EVENT_CONN_SUCCESS:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 debug_printf("main_callback: CONNECTED AGAIN!?\n");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 case GG_EVENT_CONN_FAILED:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 if (gc->inpa)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 gaim_input_remove(gc->inpa);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 handle_errcode(e->event.failure, TRUE);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 case GG_EVENT_MSG:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 gchar *imsg;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 gchar user[20];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
384 g_snprintf(user, sizeof(user), "%lu", e->event.msg.sender);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 if (!allowed_uin(gc, user))
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 imsg = charset_convert(e->event.msg.message, "CP1250", find_local_charset());
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
388 /* e->event.msg.time - we don't know what this time is for */
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 serv_got_im(gc, user, imsg, 0, time((time_t) NULL));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 g_free(imsg);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 case GG_EVENT_NOTIFY:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 gchar user[20];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 struct gg_notify_reply *n = e->event.notify;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 guint status;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 while (n->uin) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 switch (n->status) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 case GG_STATUS_NOT_AVAIL:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 status = UC_UNAVAILABLE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 case GG_STATUS_AVAIL:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 case GG_STATUS_BUSY:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 case GG_STATUS_INVISIBLE:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 case GG_STATUS_FRIENDS_MASK:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 status = UC_NORMAL | (e->event.status.status << 5);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 default:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 status = UC_NORMAL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
415 g_snprintf(user, sizeof(user), "%lu", n->uin);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0,
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 status, 0);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 n++;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 case GG_EVENT_STATUS:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 gchar user[20];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 guint status;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 switch (e->event.status.status) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 case GG_STATUS_NOT_AVAIL:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 status = UC_UNAVAILABLE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 case GG_STATUS_AVAIL:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 case GG_STATUS_BUSY:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 case GG_STATUS_INVISIBLE:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 case GG_STATUS_FRIENDS_MASK:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 status = UC_NORMAL | (e->event.status.status << 5);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 default:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 status = UC_NORMAL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
442 g_snprintf(user, sizeof(user), "%lu", e->event.status.uin);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 serv_got_update(gc, user, (status == UC_UNAVAILABLE) ? 0 : 1, 0, 0, 0, status,
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 0);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 case GG_EVENT_ACK:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 debug_printf("main_callback: message %d to %u sent with status %d\n",
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 e->event.ack.seq, e->event.ack.recipient, e->event.ack.status);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 default:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 debug_printf("main_callback: unsupported event %d\n", e->type);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 gg_free_event(e);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 static void login_callback(gpointer data, gint source, GaimInputCondition cond)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 struct gaim_connection *gc = data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 struct agg_data *gd = gc->proto_data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 struct gg_event *e;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 if (!g_slist_find(connections, data)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 close(source);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 if (gd->sess->fd != source)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 gd->sess->fd = source;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 if (source == -1) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 hide_login_progress(gc, _("Unable to connect."));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478 if (gc->inpa == 0)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, login_callback, gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
480
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 switch (gd->sess->state) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482 case GG_STATE_CONNECTING_HTTP:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 case GG_STATE_WRITING_HTTP:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 set_login_progress(gc, 2, _("Handshake"));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 case GG_STATE_CONNECTING_GG:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 set_login_progress(gc, 3, _("Connecting to GG server"));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 case GG_STATE_WAITING_FOR_KEY:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 set_login_progress(gc, 4, _("Waiting for server key"));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
490 case GG_STATE_SENDING_KEY:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 set_login_progress(gc, 5, _("Sending key"));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493 default:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 if (!(e = gg_watch_fd(gd->sess))) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 debug_printf("login_callback: gg_watch_fd failed - CRITICAL!\n");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 switch (e->type) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 case GG_EVENT_NONE:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 /* nothing */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 case GG_EVENT_CONN_SUCCESS:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508 /* Setup new input handler */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 if (gc->inpa)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510 gaim_input_remove(gc->inpa);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511 gc->inpa = gaim_input_add(gd->sess->fd, GAIM_INPUT_READ, main_callback, gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513 /* Our signon is complete */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
514 account_online(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 serv_finish_login(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516
2518
e7478176e760 [gaim-migrate @ 2531]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
517 if (bud_list_cache_exists(gc))
e7478176e760 [gaim-migrate @ 2531]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
518 do_import(gc, NULL);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 case GG_EVENT_CONN_FAILED:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521 gaim_input_remove(gc->inpa);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522 gc->inpa = 0;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 handle_errcode(e->event.failure, TRUE);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
525 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526 default:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
527 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
528 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
529
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
530 gg_free_event(e);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
532
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533 static void agg_keepalive(struct gaim_connection *gc)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535 struct agg_data *gd = (struct agg_data *)gc->proto_data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 if (gg_ping(gd->sess) < 0) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542 static void agg_login(struct aim_user *user)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 struct gaim_connection *gc = new_gaim_conn(user);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 struct agg_data *gd = gc->proto_data = g_new0(struct agg_data, 1);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 char buf[80];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547
2706
e841b14b5b89 [gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
548 gc->checkbox = _("Send as message");
e841b14b5b89 [gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
549
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 gd->sess = g_new0(struct gg_session, 1);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 if (user->proto_opt[USEROPT_NICK][0])
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s",
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 user->proto_opt[USEROPT_NICK]);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 set_login_progress(gc, 1, _("Looking up GG server"));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 if (invalid_uin(user->username)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559 hide_login_progress(gc, _("Invalid Gadu-Gadu UIN specified"));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
560 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
562 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
564 gc->inpa = 0;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
566 /*
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
567 if (gg_login(gd->sess, strtol(user->username, (char **)NULL, 10), user->password, 1) < 0) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568 debug_printf("uin=%u, pass=%s", strtol(user->username, (char **)NULL, 10), user->password);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569 hide_login_progress(gc, "Unable to connect.");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
572 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
574 gg_login() sucks for me, so I'm using proxy_connect()
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575 */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
576
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 gd->sess->uin = (uin_t) strtol(user->username, (char **)NULL, 10);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
578 gd->sess->password = g_strdup(user->password);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
579 gd->sess->state = GG_STATE_CONNECTING_HTTP;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
580 gd->sess->check = GG_CHECK_WRITE;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 gd->sess->async = 1;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
582 gd->sess->fd = proxy_connect(GG_APPMSG_HOST, GG_APPMSG_PORT, login_callback, gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
584 if (gd->sess->fd < 0) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), GG_APPMSG_HOST);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
586 hide_login_progress(gc, buf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587 signoff(gc);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
588 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
589 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
590 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
591
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
592 static void agg_close(struct gaim_connection *gc)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
593 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
594 struct agg_data *gd = (struct agg_data *)gc->proto_data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
595 if (gc->inpa)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
596 gaim_input_remove(gc->inpa);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
597 gg_logoff(gd->sess);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 gg_free_session(gd->sess);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
599 g_free(gc->proto_data);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
600 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
601
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
602 static int agg_send_im(struct gaim_connection *gc, char *who, char *msg, int flags)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 struct agg_data *gd = (struct agg_data *)gc->proto_data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
605 gchar *imsg;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
606
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 if (invalid_uin(who)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608 do_error_dialog(_("You are trying to send message to invalid Gadu-Gadu UIN!"),
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
609 _("Gadu-Gadu Error"));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
610 return -1;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
611 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
612
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
613 if (strlen(msg) > 0) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
614 imsg = charset_convert(msg, find_local_charset(), "CP1250");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
615 if (gg_send_message(gd->sess, (flags & IM_FLAG_CHECKBOX) ? GG_CLASS_MSG : GG_CLASS_CHAT,
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616 strtol(who, (char **)NULL, 10), imsg) < 0)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
617 return -1;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
618 g_free(imsg);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
619 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
620 return 1;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
623 static void agg_add_buddy(struct gaim_connection *gc, char *who)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625 struct agg_data *gd = (struct agg_data *)gc->proto_data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 if (invalid_uin(who))
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
628 gg_add_notify(gd->sess, strtol(who, (char **)NULL, 10));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2563
diff changeset
631 static void agg_rem_buddy(struct gaim_connection *gc, char *who, char *group)
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633 struct agg_data *gd = (struct agg_data *)gc->proto_data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634 if (invalid_uin(who))
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636 gg_remove_notify(gd->sess, strtol(who, (char **)NULL, 10));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
638
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639 static void agg_add_buddies(struct gaim_connection *gc, GList *whos)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
640 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 struct agg_data *gd = (struct agg_data *)gc->proto_data;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642 uin_t *userlist = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 int userlist_size = 0;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
644
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645 while (whos) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
646 if (!invalid_uin(whos->data)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647 userlist_size++;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648 userlist = g_renew(uin_t, userlist, userlist_size);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649 userlist[userlist_size - 1] =
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 (uin_t) strtol((char *)whos->data, (char **)NULL, 10);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652 whos = g_list_next(whos);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 if (userlist) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 gg_notify(gd->sess, userlist, userlist_size);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 g_free(userlist);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
661 static void search_results(struct gaim_connection *gc, gchar *webdata)
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 {
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
663 gchar **webdata_tbl;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 gchar *buf;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 char *ptr;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 int i, j;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668 if ((ptr = strstr(webdata, "query_results:")) == NULL || (ptr = strchr(ptr, '\n')) == NULL) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669 debug_printf("search_callback: pubdir result [%s]\n", webdata);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 do_error_dialog(_("Couldn't get search results"), _("Gadu-Gadu Error"));
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
672 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
673 ptr++;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
674
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
675 buf = g_strconcat("<B>", _("Gadu-Gadu Search Engine"), "</B><BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
676
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
677 webdata_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679 j = 0;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
680
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
681 /* Parse array */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682 for (i = 0; webdata_tbl[i] != NULL; i++) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683 gchar *p, *oldibuf;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684 static gchar *ibuf;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
685
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 g_strdelimit(webdata_tbl[i], "\t\n", ' ');
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 /* GG_PUBDIR_HOST service returns 7 lines of data per directory entry */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 if (i % 8 == 0)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690 j = 0;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 p = charset_convert(g_strstrip(webdata_tbl[i]), "CP1250", find_local_charset());
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694 oldibuf = ibuf;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696 switch (j) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697 case 0:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
698 ibuf = g_strconcat("---------------------------------<BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699 oldibuf = ibuf;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700 ibuf = g_strconcat(oldibuf, "<B>", _("Active"), ":</B> ",
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 (atoi(p) == 2) ? _("yes") : _("no"), "<BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
702 g_free(oldibuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 case 1:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
705 ibuf = g_strconcat(oldibuf, "<B>", _("UIN"), ":</B> ", p, "<BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706 g_free(oldibuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
707 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
708 case 2:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
709 ibuf = g_strconcat(oldibuf, "<B>", _("First name"), ":</B> ", p, "<BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 g_free(oldibuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
712 case 3:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713 ibuf =
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 g_strconcat(oldibuf, "<B>", _("Second Name"), ":</B> ", p, "<BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 g_free(oldibuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
717 case 4:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
718 ibuf = g_strconcat(oldibuf, "<B>", _("Nick"), ":</B> ", p, "<BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
719 g_free(oldibuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
720 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
721 case 5:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
722 /* Hack, invalid_uin does what we really want here but may change in future */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
723 if (invalid_uin(p))
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724 ibuf =
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725 g_strconcat(oldibuf, "<B>", _("Birth year"), ":</B> <BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 else
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 ibuf =
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
728 g_strconcat(oldibuf, "<B>", _("Birth year"), ":</B> ", p, "<BR>\n",
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729 NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
730 g_free(oldibuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
731 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 case 6:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733 if (atoi(p) == GG_GENDER_FEMALE)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> woman<BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 else if (atoi(p) == GG_GENDER_MALE)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
736 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> man<BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
737 else
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 ibuf = g_strconcat(oldibuf, "<B>", _("Sex"), ":</B> <BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
739 g_free(oldibuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741 case 7:
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 ibuf = g_strconcat(oldibuf, "<B>", _("City"), ":</B> ", p, "<BR>\n", NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
743 g_free(oldibuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
744
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
745 /* We have all lines, so add them to buffer */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
746 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
747 gchar *oldbuf = buf;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748 buf = g_strconcat(oldbuf, ibuf, NULL);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
749 g_free(oldbuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
750 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
751
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
752 g_free(ibuf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
753 break;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
754 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
756 g_free(p);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
758 j++;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
761 g_strfreev(webdata_tbl);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762
2791
8f6365332a05 [gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
763 g_show_info_text(gc, NULL, 2, buf, NULL);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765 g_free(buf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
766 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
767
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
768 static void import_buddies_server_results(struct gaim_connection *gc, gchar *webdata)
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
769 {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
770 gchar *ptr;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
771 gchar **users_tbl;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
772 int i;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
773 if (strstr(webdata, "no_data:")) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
774 do_error_dialog(_("There is no Buddy List stored on server. Sorry!"),
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
775 _("Gadu-Gadu Error"));
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
776 return;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
777 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
778
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
779 if ((ptr = strstr(webdata, "get_results:")) == NULL || (ptr = strchr(ptr, ':')) == NULL) {
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
780 debug_printf("import_buddies_server_results: import buddies result [%s]\n", webdata);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
781 do_error_dialog(_("Couldn't Import Buddies List from Server"), _("Gadu-Gadu Error"));
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
782 return;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
783 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
784 ptr++;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
785
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
786 users_tbl = g_strsplit(ptr, "\n", AGG_PUBDIR_MAX_ENTRIES);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
787
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
788 /* Parse array of Buddies List */
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
789 for (i = 0; users_tbl[i] != NULL; i++) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
790 gchar **data_tbl;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
791 gchar *name, *show;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
793 g_strdelimit(users_tbl[i], "\r\t\n\015", ' ');
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
794 data_tbl = g_strsplit(users_tbl[i], ";", 8);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
795
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
796 show = data_tbl[3];
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
797 name = data_tbl[6];
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
798
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
799 if (invalid_uin(name)) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
800 continue;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
801 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
802
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
803 debug_printf("import_buddies_server_results: uin: %s\n", name);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
804 if (!find_buddy(gc, name)) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
805 /* Default group if none specified on server */
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
806 gchar *group = g_strdup("Gadu-Gadu");
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
807 if (strlen(data_tbl[5])) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
808 gchar **group_tbl = g_strsplit(data_tbl[5], ",", 2);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
809 if (strlen(group_tbl[0])) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
810 g_free(group);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
811 group = g_strdup(group_tbl[0]);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
812 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
813 g_strfreev(group_tbl);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
814 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
815 /* Add Buddy to our userlist */
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
816 add_buddy(gc, group, name, strlen(show) ? show : name);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
817 do_export(gc);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
818 g_free(group);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
819 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
820 g_strfreev(data_tbl);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
821 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
822 g_strfreev(users_tbl);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
823 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
824
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
825 static void export_buddies_server_results(struct gaim_connection *gc, gchar *webdata)
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826 {
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
827 if (strstr(webdata, "put_success:")) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
828 do_error_dialog(_("Buddies List sucessfully transfered into Server"),
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
829 _("Gadu-Gadu Information"));
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
830 return;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
831 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
832
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
833 debug_printf("export_buddies_server_results: webdata [%s]\n", webdata);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
834 do_error_dialog(_("Couldn't transfer Buddies List into Server"), _("Gadu-Gadu Error"));
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
835 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
836
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
837 static void delete_buddies_server_results(struct gaim_connection *gc, gchar *webdata)
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
838 {
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
839 if (strstr(webdata, "put_success:")) {
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
840 do_error_dialog(_("Buddies List sucessfully deleted from Server"),
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
841 _("Gadu-Gadu Information"));
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
842 return;
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
843 }
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
844
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
845 debug_printf("delete_buddies_server_results: webdata [%s]\n", webdata);
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
846 do_error_dialog(_("Couldn't delete Buddies List from Server"), _("Gadu-Gadu Error"));
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
847 }
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
848
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
849 static void http_results(gpointer data, gint source, GaimInputCondition cond)
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
850 {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
851 struct agg_http *hdata = data;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
852 struct gaim_connection *gc = hdata->gc;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
853 char *webdata;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
854 int len;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
855 char read_data;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
856
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
857 debug_printf("http_results: begin\n");
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
858
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
859 if (!g_slist_find(connections, gc)) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
860 debug_printf("search_callback: g_slist_find error\n");
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
861 gaim_input_remove(hdata->inpa);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
862 g_free(hdata);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
863 close(source);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
864 return;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
865 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
866
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
867 webdata = NULL;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
868 len = 0;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
869
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
870 while (read(source, &read_data, 1) > 0 || errno == EWOULDBLOCK) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
871 if (errno == EWOULDBLOCK) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
872 errno = 0;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
873 continue;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
874 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
875
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
876 if (!read_data)
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
877 continue;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
878
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
879 len++;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
880 webdata = g_realloc(webdata, len);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
881 webdata[len - 1] = read_data;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
882 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
883
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
884 webdata = g_realloc(webdata, len + 1);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
885 webdata[len] = 0;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
886
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
887 gaim_input_remove(hdata->inpa);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
888 close(source);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
889
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
890 debug_printf("http_results: type %d, webdata [%s]\n", hdata->type, webdata);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
891
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
892 switch (hdata->type) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
893 case AGG_HTTP_SEARCH:
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
894 search_results(gc, webdata);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
895 break;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
896 case AGG_HTTP_USERLIST_IMPORT:
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
897 import_buddies_server_results(gc, webdata);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
898 break;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
899 case AGG_HTTP_USERLIST_EXPORT:
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
900 export_buddies_server_results(gc, webdata);
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
901 break;
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
902 case AGG_HTTP_USERLIST_DELETE:
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
903 delete_buddies_server_results(gc, webdata);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
904 break;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
905 case AGG_HTTP_NONE:
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
906 default:
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
907 debug_printf("http_results: unsupported type %d\n", hdata->type);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
908 break;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
909 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
910
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
911 g_free(webdata);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
912 g_free(hdata);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
913 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
914
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
915 static void http_req_callback(gpointer data, gint source, GaimInputCondition cond)
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
916 {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
917 struct agg_http *hdata = data;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
918 struct gaim_connection *gc = hdata->gc;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
919 gchar *request = hdata->request;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
920 gchar *buf;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
921 char *ptr;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
922
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
923 debug_printf("http_req_callback: begin\n");
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
924
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
925 if (!g_slist_find(connections, gc)) {
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
926 debug_printf("http_req_callback: g_slist_find error\n");
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
927 g_free(request);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
928 g_free(hdata);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
929 close(source);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
930 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
931 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
932
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
933 if (source == -1) {
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
934 g_free(request);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
935 g_free(hdata);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
936 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
938
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
939 ptr = encode_postdata(request);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
940 g_free(request);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
941
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
942 debug_printf("http_req_callback: http request [%s]\n", ptr);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
943
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
944 buf = g_strdup_printf("POST %s HTTP/1.0\r\n"
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
945 "Host: %s\r\n"
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
946 "Content-Type: application/x-www-form-urlencoded\r\n"
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
947 "User-Agent: " GG_HTTP_USERAGENT "\r\n"
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
948 "Content-Length: %d\r\n"
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
949 "Pragma: no-cache\r\n" "\r\n" "%s\r\n",
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
950 hdata->form, hdata->host, strlen(ptr), ptr);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
952 g_free(ptr);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
953
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
954 if (write(source, buf, strlen(buf)) < strlen(buf)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
955 g_free(buf);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
956 g_free(hdata);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
957 close(source);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
958 do_error_dialog(_("Couldn't send http request"), _("Gadu-Gadu Error"));
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
959 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
960 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
962 g_free(buf);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
963
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
964 hdata->inpa = gaim_input_add(source, GAIM_INPUT_READ, http_results, hdata);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
965 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
966
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
967 static void import_buddies_server(struct gaim_connection *gc)
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
968 {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
969 struct agg_http *hi = g_new0(struct agg_http, 1);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
970 static char msg[AGG_BUF_LEN];
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
971
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
972 hi->gc = gc;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
973 hi->type = AGG_HTTP_USERLIST_IMPORT;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
974 hi->form = AGG_PUBDIR_USERLIST_IMPORT_FORM;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
975 hi->host = GG_PUBDIR_HOST;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
976 hi->request = g_strdup_printf("FmNum=%s&Pass=%s", gc->username, gc->password);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
977
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
978 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, hi) < 0) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
979 g_snprintf(msg, sizeof(msg), _("Buddies List import from Server failed (%s)"),
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
980 GG_PUBDIR_HOST);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
981 do_error_dialog(msg, _("Gadu-Gadu Error"));
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
982 g_free(hi->request);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
983 g_free(hi);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
984 return;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
985 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
986 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
987
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
988 static void export_buddies_server(struct gaim_connection *gc)
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
989 {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
990 struct agg_http *he = g_new0(struct agg_http, 1);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
991 static char msg[AGG_BUF_LEN];
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
992 gchar *ptr;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
993 GSList *gr = gc->groups;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
994
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
995 he->gc = gc;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
996 he->type = AGG_HTTP_USERLIST_EXPORT;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
997 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
998 he->host = GG_PUBDIR_HOST;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
999 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Contacts=", gc->username, gc->password);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1000
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1001 while (gr) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1002 struct group *g = gr->data;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1003 GSList *m = g->members;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1004 while (m) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1005 struct buddy *b = m->data;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1006 gchar *newdata;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1007 /* GG Number */
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1008 gchar *name = b->name;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1009 /* GG Pseudo */
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1010 gchar *show = strlen(b->show) ? b->show : b->name;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1011
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1012 ptr = he->request;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1013 newdata = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s\r\n",
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1014 show, show, show, show, "", g->name, name);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1015 he->request = g_strconcat(ptr, newdata, NULL);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1016 g_free(newdata);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1017 g_free(ptr);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1018
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1019 m = g_slist_next(m);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1020 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1021 gr = g_slist_next(gr);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1022 }
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1023
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1024 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) {
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1025 g_snprintf(msg, sizeof(msg), _("Buddies List export to Server failed (%s)"),
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1026 GG_PUBDIR_HOST);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1027 do_error_dialog(msg, _("Gadu-Gadu Error"));
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1028 g_free(he->request);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1029 g_free(he);
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1030 return;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1031 }
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1034 static void delete_buddies_server(struct gaim_connection *gc)
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1035 {
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1036 struct agg_http *he = g_new0(struct agg_http, 1);
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1037 static char msg[AGG_BUF_LEN];
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1038
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1039 he->gc = gc;
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1040 he->type = AGG_HTTP_USERLIST_DELETE;
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1041 he->form = AGG_PUBDIR_USERLIST_EXPORT_FORM;
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1042 he->host = GG_PUBDIR_HOST;
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1043 he->request = g_strdup_printf("FmNum=%s&Pass=%s&Delete=1", gc->username, gc->password);
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1044
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1045 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, he) < 0) {
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1046 g_snprintf(msg, sizeof(msg), _("Deletion of Buddies List from Server failed (%s)"),
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1047 GG_PUBDIR_HOST);
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1048 do_error_dialog(msg, _("Gadu-Gadu Error"));
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1049 g_free(he->request);
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1050 g_free(he);
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1051 return;
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1052 }
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1053 }
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1054
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1055 static void agg_dir_search(struct gaim_connection *gc, char *first, char *middle,
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1056 char *last, char *maiden, char *city, char *state, char *country, char *email)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 {
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1058 struct agg_http *srch = g_new0(struct agg_http, 1);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059 static char msg[AGG_BUF_LEN];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1060
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 srch->gc = gc;
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1062 srch->type = AGG_HTTP_SEARCH;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1063 srch->form = AGG_PUBDIR_SEARCH_FORM;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1064 srch->host = GG_PUBDIR_HOST;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1065
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1066 if (email && strlen(email)) {
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1067 srch->request = g_strdup_printf("Mode=1&Email=%s", email);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1068 } else {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1069 gchar *new_first = charset_convert(first, find_local_charset(), "CP1250");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1070 gchar *new_last = charset_convert(last, find_local_charset(), "CP1250");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1071 gchar *new_city = charset_convert(city, find_local_charset(), "CP1250");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1072
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1073 /* For active only add &ActiveOnly= */
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1074 srch->request = g_strdup_printf("Mode=0&FirstName=%s&LastName=%s&Gender=%d"
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1075 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d",
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1076 new_first, new_last, AGG_GENDER_NONE,
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1077 "", new_city, 0, 0);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1078
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1079 g_free(new_first);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1080 g_free(new_last);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1081 g_free(new_city);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1082 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1083
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1084 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) {
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 g_snprintf(msg, sizeof(msg), _("Connect to search service failed (%s)"), GG_PUBDIR_HOST);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1086 do_error_dialog(msg, _("Gadu-Gadu Error"));
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1087 g_free(srch->request);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1088 g_free(srch);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1089 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1091 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1092
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 static void agg_do_action(struct gaim_connection *gc, char *action)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1094 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1095 if (!strcmp(action, _("Directory Search"))) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1096 show_find_info(gc);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1097 } else if (!strcmp(action, _("Import Buddies List from Server"))) {
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1098 import_buddies_server(gc);
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1099 } else if (!strcmp(action, _("Export Buddies List to Server"))) {
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1100 export_buddies_server(gc);
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1101 } else if (!strcmp(action, _("Delete Buddies List from Server"))) {
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1102 delete_buddies_server(gc);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1103 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1104 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1105
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1106 static GList *agg_actions()
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 GList *m = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1109
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110 m = g_list_append(m, _("Directory Search"));
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1111 m = g_list_append(m, _("Import Buddies List from Server"));
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1112 m = g_list_append(m, _("Export Buddies List to Server"));
2806
1ffac7cf4e94 [gaim-migrate @ 2819]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2792
diff changeset
1113 m = g_list_append(m, _("Delete Buddies List from Server"));
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1114
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1115 return m;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1116 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1117
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1118 static void agg_get_info(struct gaim_connection *gc, char *who)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 {
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1120 struct agg_http *srch = g_new0(struct agg_http, 1);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1121 static char msg[AGG_BUF_LEN];
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1122
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1123 srch->gc = gc;
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1124 srch->type = AGG_HTTP_SEARCH;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1125 srch->form = AGG_PUBDIR_SEARCH_FORM;
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1126 srch->host = GG_PUBDIR_HOST;
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1127
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1128 /* If it's invalid uin then maybe it's nickname? */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129 if (invalid_uin(who)) {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 gchar *new_who = charset_convert(who, find_local_charset(), "CP1250");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1132 srch->request = g_strdup_printf("Mode=0&FirstName=%s&LastName=%s&Gender=%d"
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1133 "&NickName=%s&City=%s&MinBirth=%d&MaxBirth=%d",
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1134 "", "", AGG_GENDER_NONE, new_who, "", 0, 0);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1135
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1136 g_free(new_who);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1137 } else
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1138 srch->request = g_strdup_printf("Mode=3&UserId=%s", who);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1139
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1140 if (proxy_connect(GG_PUBDIR_HOST, GG_PUBDIR_PORT, http_req_callback, srch) < 0) {
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1141 g_snprintf(msg, sizeof(msg), _("Connect to search service failed (%s)"), GG_PUBDIR_HOST);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1142 do_error_dialog(msg, _("Gadu-Gadu Error"));
2792
9123abd0db92 [gaim-migrate @ 2805]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1143 g_free(srch->request);
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1144 g_free(srch);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1145 return;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1146 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1147 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1148
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1149 static char **agg_list_icon(int uc)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1150 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1151 guint status;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1152 if (uc == UC_UNAVAILABLE)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 return (char **)gg_sunred_xpm;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 status = uc >> 5;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1155 /* Drop all masks */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1156 status &= ~(GG_STATUS_FRIENDS_MASK);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1157 if (status == GG_STATUS_AVAIL)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1158 return (char **)gg_sunyellow_xpm;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1159 if (status == GG_STATUS_BUSY)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1160 return (char **)gg_suncloud_xpm;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1161 if (status == GG_STATUS_INVISIBLE)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1162 return (char **)gg_sunwhitered_xpm;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1163 return (char **)gg_sunyellow_xpm;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1164 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1166 static void agg_set_permit_deny_dummy(struct gaim_connection *gc)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1167 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1168 /* It's implemented on client side because GG server doesn't support this */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1170
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1171 static void agg_permit_deny_dummy(struct gaim_connection *gc, char *who)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1172 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1173 /* It's implemented on client side because GG server doesn't support this */
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1174 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1176 static struct prpl *my_protocol = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1177
2423
ce09589b7681 [gaim-migrate @ 2436]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
1178 void gg_init(struct prpl *ret)
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1179 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180 ret->protocol = PROTO_GADUGADU;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181 ret->options = 0;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 ret->name = agg_name;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183 ret->list_icon = agg_list_icon;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1184 ret->away_states = agg_away_states;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185 ret->actions = agg_actions;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1186 ret->do_action = agg_do_action;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 ret->user_opts = agg_user_opts;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 ret->buddy_menu = agg_buddy_menu;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189 ret->chat_info = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 ret->login = agg_login;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191 ret->close = agg_close;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1192 ret->send_im = agg_send_im;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193 ret->set_info = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194 ret->get_info = agg_get_info;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1195 ret->set_away = agg_set_away;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196 ret->set_dir = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197 ret->get_dir = agg_get_info;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1198 ret->dir_search = agg_dir_search;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1199 ret->set_idle = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200 ret->change_passwd = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201 ret->add_buddy = agg_add_buddy;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202 ret->add_buddies = agg_add_buddies;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1203 ret->remove_buddy = agg_rem_buddy;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1204 ret->add_permit = agg_permit_deny_dummy;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1205 ret->add_deny = agg_permit_deny_dummy;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206 ret->rem_permit = agg_permit_deny_dummy;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1207 ret->rem_deny = agg_permit_deny_dummy;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 ret->set_permit_deny = agg_set_permit_deny_dummy;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209 ret->warn = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 ret->join_chat = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 ret->chat_invite = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1212 ret->chat_leave = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1213 ret->chat_whisper = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214 ret->chat_send = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 ret->keepalive = agg_keepalive;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1216 ret->normalize = NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 my_protocol = ret;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1219
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1220 #ifndef STATIC
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222 char *gaim_plugin_init(GModule *handle)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223 {
2423
ce09589b7681 [gaim-migrate @ 2436]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
1224 load_protocol(gg_init, sizeof(struct prpl));
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1225 return NULL;
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1226 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228 void gaim_plugin_remove()
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1229 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230 struct prpl *p = find_prpl(PROTO_GADUGADU);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1231 if (p == my_protocol)
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 unload_protocol(p);
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1233 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1234
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1235 char *name()
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1236 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1237 return "Gadu-Gadu";
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240 char *description()
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1241 {
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1242 return PRPL_DESC("Gadu-Gadu");
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 }
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1244
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1245 #endif