Mercurial > pidgin.yaz
annotate plugins/jabber/jabber.c @ 1872:efc899af4912
[gaim-migrate @ 1882]
waah
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 21 May 2001 17:38:20 +0000 |
parents | 28921530e20b |
children | 08ac51210d09 |
rev | line source |
---|---|
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
1311 | 2 /* |
3 * gaim | |
4 * | |
5 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
1514
0dd012166152
[gaim-migrate @ 1524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
25 #include "config.h" |
1311 | 26 #endif |
27 | |
28 | |
1312
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
29 #include <gtk/gtk.h> |
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
30 #ifdef MAX |
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
31 #undef MAX |
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
32 #endif |
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
33 #ifdef MIN |
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
34 #undef MIN |
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
35 #endif |
1311 | 36 #include <netdb.h> |
37 #include <unistd.h> | |
38 #include <errno.h> | |
39 #include <netinet/in.h> | |
40 #include <arpa/inet.h> | |
41 #include <string.h> | |
42 #include <stdlib.h> | |
43 #include <stdio.h> | |
44 #include <time.h> | |
45 #include <sys/socket.h> | |
1789
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
46 #include <sys/utsname.h> |
1311 | 47 #include <sys/stat.h> |
48 #include "multi.h" | |
49 #include "prpl.h" | |
50 #include "gaim.h" | |
1347
afa63ac2fd84
[gaim-migrate @ 1357]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1345
diff
changeset
|
51 #include "jabber.h" |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
52 #include "proxy.h" |
1311 | 53 |
1344
8b5ed2f0496c
[gaim-migrate @ 1354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1331
diff
changeset
|
54 #include "pixmaps/available.xpm" |
1354
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
55 #include "pixmaps/available-away.xpm" |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
56 #include "pixmaps/available-chat.xpm" |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
57 #include "pixmaps/available-xa.xpm" |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
58 #include "pixmaps/available-dnd.xpm" |
1344
8b5ed2f0496c
[gaim-migrate @ 1354]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1331
diff
changeset
|
59 |
1311 | 60 /* The priv member of gjconn's is a gaim_connection for now. */ |
61 #define GJ_GC(x) ((struct gaim_connection *)(x)->priv) | |
62 | |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
63 #define IQID_AUTH "__AUTH__" |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
64 |
1311 | 65 #define IQ_NONE -1 |
66 #define IQ_AUTH 0 | |
67 #define IQ_ROSTER 1 | |
68 | |
1354
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
69 #define UC_AWAY 0x38 |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
70 #define UC_CHAT 0x48 |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
71 #define UC_XA 0x98 |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
72 #define UC_DND 0x118 |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
73 |
1469
d74112de59ed
[gaim-migrate @ 1479]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1466
diff
changeset
|
74 #define DEFAULT_SERVER "jabber.org" |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
75 #define DEFAULT_GROUPCHAT "conference.jabber.org" |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
76 |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
77 #define USEROPT_PROXYSERV 2 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
78 #define USEROPT_PROXYPORT 3 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
79 #define USEROPT_PROXYTYPE 4 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
80 #define USEROPT_USER 5 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
81 #define USEROPT_PASS 6 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
82 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
83 typedef struct gjconn_struct { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
84 /* Core structure */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
85 pool p; /* Memory allocation pool */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
86 int state; /* Connection state flag */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
87 int fd; /* Connection file descriptor */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
88 jid user; /* User info */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
89 char *pass; /* User passwd */ |
1311 | 90 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
91 /* Stream stuff */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
92 int id; /* id counter for jab_getid() function */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
93 char idbuf[9]; /* temporary storage for jab_getid() */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
94 char *sid; /* stream id from server, for digest auth */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
95 XML_Parser parser; /* Parser instance */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
96 xmlnode current; /* Current node in parsing instance.. */ |
1311 | 97 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
98 /* Event callback ptrs */ |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
99 void (*on_state)(struct gjconn_struct *j, int state); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
100 void (*on_packet)(struct gjconn_struct *j, jpacket p); |
1311 | 101 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
102 void *priv; |
1311 | 103 |
104 } *gjconn, gjconn_struct; | |
105 | |
106 typedef void (*gjconn_state_h)(gjconn j, int state); | |
107 typedef void (*gjconn_packet_h)(gjconn j, jpacket p); | |
108 | |
109 static gjconn gjab_new(char *user, char *pass, void *priv); | |
110 static void gjab_delete(gjconn j); | |
111 static void gjab_state_handler(gjconn j, gjconn_state_h h); | |
112 static void gjab_packet_handler(gjconn j, gjconn_packet_h h); | |
1331
f48cb8ddca59
[gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1316
diff
changeset
|
113 static void gjab_start(gjconn j); |
1311 | 114 static void gjab_stop(gjconn j); |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
115 /* |
1311 | 116 static int gjab_getfd(gjconn j); |
117 static jid gjab_getjid(gjconn j); | |
118 static char *gjab_getsid(gjconn j); | |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
119 */ |
1311 | 120 static char *gjab_getid(gjconn j); |
121 static void gjab_send(gjconn j, xmlnode x); | |
122 static void gjab_send_raw(gjconn j, const char *str); | |
123 static void gjab_recv(gjconn j); | |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
124 static void gjab_auth(gjconn j); |
1311 | 125 |
126 struct jabber_data { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
127 gjconn jc; |
1362
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
128 gboolean did_import; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
129 GSList *pending_chats; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
130 GSList *existing_chats; |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
131 GHashTable *hash; |
1789
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
132 time_t idle; |
1311 | 133 }; |
134 | |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
135 struct jabber_chat { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
136 jid Jid; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
137 struct gaim_connection *gc; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
138 struct conversation *b; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
139 }; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
140 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
141 static char *jabber_name() |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
142 { |
1311 | 143 return "Jabber"; |
144 } | |
145 | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
146 char *name() |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
147 { |
1311 | 148 return "Jabber"; |
149 } | |
150 | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
151 char *description() |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
152 { |
1311 | 153 return "Allows gaim to use the Jabber protocol"; |
154 } | |
155 | |
156 #define STATE_EVT(arg) if(j->on_state) { (j->on_state)(j, (arg) ); } | |
157 | |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
158 static char *create_valid_jid(const char *given, char *server, char *resource) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
159 { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
160 char *valid; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
161 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
162 if (!strchr(given, '@')) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
163 valid = g_strdup_printf("%s@%s/%s", given, server, resource); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
164 else if (!strchr(strchr(given, '@'), '/')) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
165 valid = g_strdup_printf("%s/%s", given, resource); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
166 else |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
167 valid = g_strdup(given); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
168 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
169 return valid; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
170 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
171 |
1311 | 172 static gjconn gjab_new(char *user, char *pass, void *priv) |
173 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
174 pool p; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
175 gjconn j; |
1311 | 176 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
177 if (!user) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
178 return (NULL); |
1311 | 179 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
180 p = pool_new(); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
181 if (!p) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
182 return (NULL); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
183 j = pmalloc_x(p, sizeof(gjconn_struct), 0); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
184 if (!j) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
185 return (NULL); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
186 j->p = p; |
1311 | 187 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
188 j->user = jid_new(p, user); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
189 j->pass = pstrdup(p, pass); |
1311 | 190 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
191 j->state = JCONN_STATE_OFF; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
192 j->id = 1; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
193 j->fd = -1; |
1311 | 194 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
195 j->priv = priv; |
1311 | 196 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
197 return j; |
1311 | 198 } |
199 | |
200 static void gjab_delete(gjconn j) | |
201 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
202 if (!j) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
203 return; |
1311 | 204 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
205 gjab_stop(j); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
206 pool_free(j->p); |
1311 | 207 } |
208 | |
209 static void gjab_state_handler(gjconn j, gjconn_state_h h) | |
210 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
211 if (!j) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
212 return; |
1311 | 213 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
214 j->on_state = h; |
1311 | 215 } |
216 | |
217 static void gjab_packet_handler(gjconn j, gjconn_packet_h h) | |
218 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
219 if (!j) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
220 return; |
1311 | 221 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
222 j->on_packet = h; |
1311 | 223 } |
224 | |
225 static void gjab_stop(gjconn j) | |
226 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
227 if (!j || j->state == JCONN_STATE_OFF) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
228 return; |
1311 | 229 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
230 j->state = JCONN_STATE_OFF; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
231 gjab_send_raw(j, "</stream:stream>"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
232 close(j->fd); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
233 j->fd = -1; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
234 XML_ParserFree(j->parser); |
1668
91cddbcfdd17
[gaim-migrate @ 1678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1666
diff
changeset
|
235 j->parser = NULL; |
1311 | 236 } |
237 | |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
238 /* |
1311 | 239 static int gjab_getfd(gjconn j) |
240 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
241 if (j) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
242 return j->fd; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
243 else |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
244 return -1; |
1311 | 245 } |
246 | |
247 static jid gjab_getjid(gjconn j) | |
248 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
249 if (j) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
250 return (j->user); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
251 else |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
252 return NULL; |
1311 | 253 } |
254 | |
255 static char *gjab_getsid(gjconn j) | |
256 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
257 if (j) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
258 return (j->sid); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
259 else |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
260 return NULL; |
1311 | 261 } |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
262 */ |
1311 | 263 |
264 static char *gjab_getid(gjconn j) | |
265 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
266 snprintf(j->idbuf, 8, "%d", j->id++); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
267 return &j->idbuf[0]; |
1311 | 268 } |
269 | |
270 static void gjab_send(gjconn j, xmlnode x) | |
271 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
272 if (j && j->state != JCONN_STATE_OFF) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
273 char *buf = xmlnode2str(x); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
274 if (buf) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
275 write(j->fd, buf, strlen(buf)); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
276 debug_printf("gjab_send: %s\n", buf); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
277 } |
1311 | 278 } |
279 | |
280 static void gjab_send_raw(gjconn j, const char *str) | |
281 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
282 if (j && j->state != JCONN_STATE_OFF) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
283 write(j->fd, str, strlen(str)); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
284 debug_printf("gjab_send_raw: %s\n", str); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
285 } |
1311 | 286 } |
287 | |
288 static void gjab_reqroster(gjconn j) | |
289 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
290 xmlnode x; |
1311 | 291 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
292 x = jutil_iqnew(JPACKET__GET, NS_ROSTER); |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
293 xmlnode_put_attrib(x, "id", gjab_getid(j)); |
1311 | 294 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
295 gjab_send(j, x); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
296 xmlnode_free(x); |
1311 | 297 } |
298 | |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
299 static void gjab_auth(gjconn j) |
1311 | 300 { |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
301 xmlnode x, y, z; |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
302 char *hash, *user; |
1311 | 303 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
304 if (!j) |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
305 return; |
1311 | 306 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
307 x = jutil_iqnew(JPACKET__SET, NS_AUTH); |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
308 xmlnode_put_attrib(x, "id", IQID_AUTH); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
309 y = xmlnode_get_tag(x, "query"); |
1311 | 310 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
311 user = j->user->user; |
1311 | 312 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
313 if (user) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
314 z = xmlnode_insert_tag(y, "username"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
315 xmlnode_insert_cdata(z, user, -1); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
316 } |
1311 | 317 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
318 z = xmlnode_insert_tag(y, "resource"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
319 xmlnode_insert_cdata(z, j->user->resource, -1); |
1311 | 320 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
321 if (j->sid) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
322 z = xmlnode_insert_tag(y, "digest"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
323 hash = pmalloc(x->p, strlen(j->sid) + strlen(j->pass) + 1); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
324 strcpy(hash, j->sid); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
325 strcat(hash, j->pass); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
326 hash = shahash(hash); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
327 xmlnode_insert_cdata(z, hash, 40); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
328 } else { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
329 z = xmlnode_insert_tag(y, "password"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
330 xmlnode_insert_cdata(z, j->pass, -1); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
331 } |
1311 | 332 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
333 gjab_send(j, x); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
334 xmlnode_free(x); |
1311 | 335 |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
336 return; |
1311 | 337 } |
338 | |
339 static void gjab_recv(gjconn j) | |
340 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
341 static char buf[4096]; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
342 int len; |
1311 | 343 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
344 if (!j || j->state == JCONN_STATE_OFF) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
345 return; |
1311 | 346 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
347 if ((len = read(j->fd, buf, sizeof(buf) - 1))) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
348 buf[len] = '\0'; |
1668
91cddbcfdd17
[gaim-migrate @ 1678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1666
diff
changeset
|
349 debug_printf("input (len %d): %s\n", len, buf); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
350 XML_Parse(j->parser, buf, len, 0); |
1551
497a074fa1c8
[gaim-migrate @ 1561]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1522
diff
changeset
|
351 } else if (len <= 0) { |
1666
8b0c165a33f4
[gaim-migrate @ 1676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1665
diff
changeset
|
352 STATE_EVT(JCONN_STATE_OFF) |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
353 } |
1311 | 354 } |
355 | |
356 static void startElement(void *userdata, const char *name, const char **attribs) | |
357 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
358 xmlnode x; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
359 gjconn j = (gjconn) userdata; |
1311 | 360 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
361 if (j->current) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
362 /* Append the node to the current one */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
363 x = xmlnode_insert_tag(j->current, name); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
364 xmlnode_put_expat_attribs(x, attribs); |
1311 | 365 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
366 j->current = x; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
367 } else { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
368 x = xmlnode_new_tag(name); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
369 xmlnode_put_expat_attribs(x, attribs); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
370 if (strcmp(name, "stream:stream") == 0) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
371 /* special case: name == stream:stream */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
372 /* id attrib of stream is stored for digest auth */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
373 j->sid = xmlnode_get_attrib(x, "id"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
374 /* STATE_EVT(JCONN_STATE_AUTH) */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
375 } else { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
376 j->current = x; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
377 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
378 } |
1311 | 379 } |
380 | |
381 static void endElement(void *userdata, const char *name) | |
382 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
383 gjconn j = (gjconn) userdata; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
384 xmlnode x; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
385 jpacket p; |
1311 | 386 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
387 if (j->current == NULL) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
388 /* we got </stream:stream> */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
389 STATE_EVT(JCONN_STATE_OFF) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
390 return; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
391 } |
1311 | 392 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
393 x = xmlnode_get_parent(j->current); |
1311 | 394 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
395 if (!x) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
396 /* it is time to fire the event */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
397 p = jpacket_new(j->current); |
1311 | 398 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
399 if (j->on_packet) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
400 (j->on_packet) (j, p); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
401 else |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
402 xmlnode_free(j->current); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
403 } |
1311 | 404 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
405 j->current = x; |
1311 | 406 } |
407 | |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
408 static void jabber_callback(gpointer data, gint source, GdkInputCondition condition) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
409 { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
410 struct gaim_connection *gc = (struct gaim_connection *)data; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
411 struct jabber_data *jd = (struct jabber_data *)gc->proto_data; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
412 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
413 gjab_recv(jd->jc); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
414 } |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
415 |
1311 | 416 static void charData(void *userdata, const char *s, int slen) |
417 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
418 gjconn j = (gjconn) userdata; |
1311 | 419 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
420 if (j->current) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
421 xmlnode_insert_cdata(j->current, s, slen); |
1311 | 422 } |
423 | |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
424 static void gjab_connected(gpointer data, gint source, GdkInputCondition cond) |
1311 | 425 { |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
426 xmlnode x; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
427 char *t, *t2; |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
428 gjconn j = data; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
429 struct gaim_connection *gc; |
1311 | 430 |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
431 if (source == -1) { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
432 STATE_EVT(JCONN_STATE_OFF) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
433 return; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
434 } |
1311 | 435 |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
436 if (j->fd != source) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
437 j->fd = source; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
438 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
439 j->state = JCONN_STATE_CONNECTED; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
440 STATE_EVT(JCONN_STATE_CONNECTED) |
1311 | 441 |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
442 /* start stream */ |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
443 x = jutil_header(NS_CLIENT, j->user->server); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
444 t = xmlnode2str(x); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
445 /* this is ugly, we can create the string here instead of jutil_header */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
446 /* what do you think about it? -madcat */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
447 t2 = strstr(t, "/>"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
448 *t2++ = '>'; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
449 *t2 = '\0'; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
450 gjab_send_raw(j, "<?xml version='1.0'?>"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
451 gjab_send_raw(j, t); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
452 xmlnode_free(x); |
1311 | 453 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
454 j->state = JCONN_STATE_ON; |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
455 STATE_EVT(JCONN_STATE_ON); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
456 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
457 gc = GJ_GC(j); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
458 gc->inpa = gdk_input_add(j->fd, GDK_INPUT_READ, jabber_callback, gc); |
1311 | 459 } |
460 | |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
461 static void gjab_start(gjconn j) |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
462 { |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
463 struct aim_user *user; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
464 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
465 if (!j || j->state != JCONN_STATE_OFF) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
466 return; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
467 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
468 user = GJ_GC(j)->user; |
1311 | 469 |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
470 j->parser = XML_ParserCreate(NULL); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
471 XML_SetUserData(j->parser, (void *)j); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
472 XML_SetElementHandler(j->parser, startElement, endElement); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
473 XML_SetCharacterDataHandler(j->parser, charData); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
474 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
475 j->fd = proxy_connect(j->user->server, 5222, |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
476 user->proto_opt[USEROPT_PROXYSERV], atoi(user->proto_opt[USEROPT_PROXYPORT]), |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
477 atoi(user->proto_opt[USEROPT_PROXYTYPE]), |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
478 user->proto_opt[USEROPT_USER], user->proto_opt[USEROPT_PASS], |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
479 gjab_connected, j); |
1866
466fc4ada7cb
[gaim-migrate @ 1876]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1865
diff
changeset
|
480 if (!user->gc || (j->fd < 0)) { |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
481 STATE_EVT(JCONN_STATE_OFF) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
482 return; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
483 } |
1311 | 484 } |
485 | |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
486 static struct conversation *find_chat(struct gaim_connection *gc, char *name) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
487 { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
488 GSList *bcs = gc->buddy_chats; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
489 struct conversation *b = NULL; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
490 char *chat = g_strdup(normalize(name)); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
491 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
492 while (bcs) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
493 b = bcs->data; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
494 if (!strcasecmp(normalize(b->name), chat)) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
495 break; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
496 b = NULL; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
497 bcs = bcs->next; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
498 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
499 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
500 g_free(chat); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
501 return b; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
502 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
503 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
504 static struct jabber_chat *find_existing_chat(struct gaim_connection *gc, jid chat) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
505 { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
506 GSList *bcs = ((struct jabber_data *)gc->proto_data)->existing_chats; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
507 struct jabber_chat *jc = NULL; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
508 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
509 while (bcs) { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
510 jc = bcs->data; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
511 if (!jid_cmpx(chat, jc->Jid, JID_USER | JID_SERVER)) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
512 break; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
513 jc = NULL; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
514 bcs = bcs->next; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
515 } |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
516 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
517 return jc; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
518 } |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
519 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
520 static struct jabber_chat *find_pending_chat(struct gaim_connection *gc, jid chat) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
521 { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
522 GSList *bcs = ((struct jabber_data *)gc->proto_data)->pending_chats; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
523 struct jabber_chat *jc = NULL; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
524 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
525 while (bcs) { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
526 jc = bcs->data; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
527 if (!jid_cmpx(chat, jc->Jid, JID_USER | JID_SERVER)) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
528 break; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
529 jc = NULL; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
530 bcs = bcs->next; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
531 } |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
532 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
533 return jc; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
534 } |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
535 |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
536 static gboolean find_chat_buddy(struct conversation *b, char *name) |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
537 { |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
538 GList *m = b->in_room; |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
539 |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
540 while (m) { |
1791
b4cc5f391133
[gaim-migrate @ 1801]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1789
diff
changeset
|
541 if (!strcmp(m->data, name)) |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
542 return TRUE; |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
543 m = m->next; |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
544 } |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
545 |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
546 return FALSE; |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
547 } |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
548 |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
549 static unsigned char *utf8_to_str(unsigned char *in) |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
550 { |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
551 int n = 0,i = 0; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
552 int inlen; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
553 unsigned char *result; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
554 |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
555 if (!in) |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
556 return NULL; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
557 |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
558 inlen = strlen(in); |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
559 |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
560 result = (unsigned char*)malloc(inlen+1); |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
561 |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
562 while(n <= inlen-1) { |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
563 long c = (long)in[n]; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
564 if(c<0x80) |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
565 result[i++] = (char)c; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
566 else { |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
567 if((c&0xC0) == 0xC0) |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
568 result[i++] = (char)(((c&0x03)<<6)|(((unsigned char)in[++n])&0x3F)); |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
569 else if((c&0xE0) == 0xE0) { |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
570 if (n + 2 <= inlen) { |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
571 result[i] = (char)(((c&0xF)<<4)|(((unsigned char)in[++n])&0x3F)); |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
572 result[i] = (char)(((unsigned char)result[i]) |(((unsigned char)in[++n])&0x3F)); |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
573 i++; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
574 } else n += 2; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
575 } |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
576 else if((c&0xF0) == 0xF0) |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
577 n += 3; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
578 else if((c&0xF8) == 0xF8) |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
579 n += 4; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
580 else if((c&0xFC) == 0xFC) |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
581 n += 5; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
582 } |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
583 n++; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
584 } |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
585 result[i] = '\0'; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
586 |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
587 return result; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
588 } |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
589 |
1311 | 590 static void jabber_handlemessage(gjconn j, jpacket p) |
591 { | |
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
592 xmlnode y, xmlns; |
1311 | 593 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
594 char *from = NULL, *msg = NULL, *type = NULL; |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
595 char m[BUF_LONG * 2]; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
596 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
597 type = xmlnode_get_attrib(p->x, "type"); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
598 |
1485
5e00250ada1e
[gaim-migrate @ 1495]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1469
diff
changeset
|
599 if (!type || !strcmp(type, "normal") || !strcmp(type, "chat")) { |
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
600 |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
601 /* XXX namespaces could be handled better. (mid) */ |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
602 if ((xmlns = xmlnode_get_tag(p->x, "x"))) |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
603 type = xmlnode_get_attrib(xmlns, "xmlns"); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
604 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
605 from = jid_full(p->from); |
1784
cf7806e63d0c
[gaim-migrate @ 1794]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1778
diff
changeset
|
606 /* |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
607 if ((y = xmlnode_get_tag(p->x, "html"))) { |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
608 msg = xmlnode_get_data(y); |
1784
cf7806e63d0c
[gaim-migrate @ 1794]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1778
diff
changeset
|
609 } else |
cf7806e63d0c
[gaim-migrate @ 1794]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1778
diff
changeset
|
610 */ |
cf7806e63d0c
[gaim-migrate @ 1794]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1778
diff
changeset
|
611 if ((y = xmlnode_get_tag(p->x, "body"))) { |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
612 msg = xmlnode_get_data(y); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
613 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
614 |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
615 msg = utf8_to_str(msg); |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
616 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
617 if (!from) |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
618 return; |
1311 | 619 |
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
620 if (type && !strcmp(type, "jabber:x:conference")) { |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
621 char *room; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
622 |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
623 room = xmlnode_get_attrib(xmlns, "jid"); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
624 |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
625 serv_got_chat_invite(GJ_GC(j), room, 0, from, msg); |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
626 } else if (msg) { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
627 struct jabber_chat *jc; |
1795
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
628 g_snprintf(m, sizeof(m), "%s", msg); |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
629 if ((jc = find_existing_chat(GJ_GC(j), p->from)) != NULL) /* whisper */ |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
630 serv_got_chat_in(GJ_GC(j), jc->b->id, p->from->resource, 1, m, time(NULL)); |
1795
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
631 else { |
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
632 if (find_conversation(jid_full(p->from))) |
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
633 serv_got_im(GJ_GC(j), jid_full(p->from), m, 0, time(NULL)); |
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
634 else { |
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
635 from = g_strdup_printf("%s@%s", p->from->user, p->from->server); |
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
636 serv_got_im(GJ_GC(j), from, m, 0, time(NULL)); |
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
637 g_free(from); |
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
638 } |
ca53277c0204
[gaim-migrate @ 1805]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1791
diff
changeset
|
639 } |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
640 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
641 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
642 if (msg) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
643 free(msg); |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
644 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
645 } else if (!strcmp(type, "error")) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
646 if ((y = xmlnode_get_tag(p->x, "error"))) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
647 type = xmlnode_get_attrib(y, "code"); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
648 msg = xmlnode_get_data(y); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
649 } |
1311 | 650 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
651 if (msg) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
652 from = g_strdup_printf("Error %s", type ? type : ""); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
653 do_error_dialog(msg, from); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
654 g_free(from); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
655 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
656 } else if (!strcmp(type, "groupchat")) { |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
657 struct jabber_chat *jc; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
658 static int i = 0; |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
659 |
1784
cf7806e63d0c
[gaim-migrate @ 1794]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1778
diff
changeset
|
660 /* |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
661 if ((y = xmlnode_get_tag(p->x, "html"))) { |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
662 msg = xmlnode_get_data(y); |
1784
cf7806e63d0c
[gaim-migrate @ 1794]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1778
diff
changeset
|
663 } else |
cf7806e63d0c
[gaim-migrate @ 1794]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1778
diff
changeset
|
664 */ |
cf7806e63d0c
[gaim-migrate @ 1794]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1778
diff
changeset
|
665 if ((y = xmlnode_get_tag(p->x, "body"))) { |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
666 msg = xmlnode_get_data(y); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
667 } |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
668 |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
669 msg = utf8_to_str(msg); |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
670 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
671 jc = find_existing_chat(GJ_GC(j), p->from); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
672 if (!jc) { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
673 /* we're not in this chat. are we supposed to be? */ |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
674 struct jabber_data *jd = GJ_GC(j)->proto_data; |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
675 if ((jc = find_pending_chat(GJ_GC(j), p->from)) != NULL) { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
676 /* yes, we're supposed to be. so now we are. */ |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
677 jc->b = serv_got_joined_chat(GJ_GC(j), i++, p->from->user); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
678 jd->existing_chats = g_slist_append(jd->existing_chats, jc); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
679 jd->pending_chats = g_slist_remove(jd->pending_chats, jc); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
680 } else { |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
681 /* no, we're not supposed to be. */ |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
682 free(msg); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
683 return; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
684 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
685 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
686 if (p->from->resource) { |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
687 if (!y) { |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
688 if (!find_chat_buddy(jc->b, p->from->resource)) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
689 add_chat_buddy(jc->b, p->from->resource); |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
690 else if ((y = xmlnode_get_tag(p->x, "status"))) { |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
691 char buf[8192]; |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
692 msg = xmlnode_get_data(y); |
1735
00f74db70f2d
[gaim-migrate @ 1745]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1724
diff
changeset
|
693 g_snprintf(buf, sizeof(buf), "%s now has status: %s", |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
694 p->from->resource, msg); |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
695 write_to_conv(jc->b, buf, WFLAG_SYSTEM, NULL, time(NULL)); |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
696 } |
1688
85d8c64e969d
[gaim-migrate @ 1698]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1684
diff
changeset
|
697 } else if (msg) { |
85d8c64e969d
[gaim-migrate @ 1698]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1684
diff
changeset
|
698 char buf[8192]; |
85d8c64e969d
[gaim-migrate @ 1698]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1684
diff
changeset
|
699 g_snprintf(buf, sizeof(buf), "%s", msg); |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
700 serv_got_chat_in(GJ_GC(j), jc->b->id, p->from->resource, 0, buf, time(NULL)); |
1688
85d8c64e969d
[gaim-migrate @ 1698]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1684
diff
changeset
|
701 } |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
702 } |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
703 |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
704 free(msg); |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
705 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
706 } else { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
707 debug_printf("unhandled message %s\n", type); |
1362
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
708 } |
1311 | 709 } |
710 | |
711 static void jabber_handlepresence(gjconn j, jpacket p) | |
712 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
713 char *to, *from, *type; |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
714 struct buddy *b = NULL; |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
715 jid who; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
716 char *buddy; |
1354
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
717 xmlnode y; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
718 char *show; |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
719 int state = UC_NORMAL; |
1359
f0c2d6b88b14
[gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1354
diff
changeset
|
720 GSList *resources; |
f0c2d6b88b14
[gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1354
diff
changeset
|
721 char *res; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
722 struct conversation *cnv = NULL; |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
723 struct jabber_chat *jc = NULL; |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
724 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
725 to = xmlnode_get_attrib(p->x, "to"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
726 from = xmlnode_get_attrib(p->x, "from"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
727 type = xmlnode_get_attrib(p->x, "type"); |
1311 | 728 |
1354
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
729 if ((y = xmlnode_get_tag(p->x, "show"))) { |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
730 show = xmlnode_get_data(y); |
1758
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
731 if (!show) { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
732 state = UC_NORMAL; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
733 } else if (!strcmp(show, "away")) { |
1354
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
734 state = UC_AWAY; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
735 } else if (!strcmp(show, "chat")) { |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
736 state = UC_CHAT; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
737 } else if (!strcmp(show, "xa")) { |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
738 state = UC_XA; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
739 } else if (!strcmp(show, "dnd")) { |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
740 state = UC_DND; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
741 } |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
742 } else { |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
743 state = UC_NORMAL; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
744 } |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
745 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
746 who = jid_new(j->p, from); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
747 if (who->user == NULL) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
748 /* FIXME: transport */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
749 return; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
750 } |
1311 | 751 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
752 buddy = g_strdup_printf("%s@%s", who->user, who->server); |
1311 | 753 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
754 /* um. we're going to check if it's a chat. if it isn't, and there are pending |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
755 * chats, create the chat. if there aren't pending chats, add the buddy. */ |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
756 if ((cnv = find_chat(GJ_GC(j), who->user)) == NULL) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
757 static int i = 0x70; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
758 struct jabber_data *jd = GJ_GC(j)->proto_data; |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
759 if ((jc = find_pending_chat(GJ_GC(j), who)) != NULL) { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
760 jc->b = cnv = serv_got_joined_chat(GJ_GC(j), i++, who->user); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
761 jd->existing_chats = g_slist_append(jd->existing_chats, jc); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
762 jd->pending_chats = g_slist_remove(jd->pending_chats, jc); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
763 } else if (!(b = find_buddy(GJ_GC(j), buddy))) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
764 b = add_buddy(GJ_GC(j), "Buddies", buddy, buddy); |
1805
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1800
diff
changeset
|
765 do_export(GJ_GC(j)); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
766 } |
1359
f0c2d6b88b14
[gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1354
diff
changeset
|
767 } |
1311 | 768 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
769 if (!cnv) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
770 resources = b->proto_data; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
771 res = who->resource; |
1611
9ff8cac19352
[gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1551
diff
changeset
|
772 if (res) |
9ff8cac19352
[gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1551
diff
changeset
|
773 while (resources) { |
9ff8cac19352
[gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1551
diff
changeset
|
774 if (!strcmp(res, resources->data)) |
9ff8cac19352
[gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1551
diff
changeset
|
775 break; |
9ff8cac19352
[gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1551
diff
changeset
|
776 resources = resources->next; |
9ff8cac19352
[gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1551
diff
changeset
|
777 } |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
778 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
779 if (type && (strcasecmp(type, "unavailable") == 0)) { |
1624
12bd198b6721
[gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1611
diff
changeset
|
780 if (resources) { |
12bd198b6721
[gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1611
diff
changeset
|
781 g_free(resources->data); |
12bd198b6721
[gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1611
diff
changeset
|
782 b->proto_data = g_slist_remove(b->proto_data, resources->data); |
12bd198b6721
[gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1611
diff
changeset
|
783 } |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
784 if (!b->proto_data) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
785 serv_got_update(GJ_GC(j), buddy, 0, 0, 0, 0, 0, 0); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
786 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
787 } else { |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
788 /* keep track of away msg same as yahoo plugin */ |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
789 struct jabber_data *jd = GJ_GC(j)->proto_data; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
790 gpointer val = g_hash_table_lookup(jd->hash, b->name); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
791 if (val) |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
792 g_free(val); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
793 g_hash_table_insert(jd->hash, g_strdup(b->name), g_strdup(xmlnode_get_tag_data(p->x, "status"))); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
794 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
795 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
796 if (!resources) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
797 b->proto_data = g_slist_append(b->proto_data, g_strdup(res)); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
798 } |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
799 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
800 serv_got_update(GJ_GC(j), buddy, 1, 0, 0, 0, state, 0); |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
801 |
1359
f0c2d6b88b14
[gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1354
diff
changeset
|
802 } |
f0c2d6b88b14
[gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1354
diff
changeset
|
803 } else { |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
804 if (who->resource) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
805 if (type && !strcmp(type, "unavailable")) { |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
806 struct jabber_data *jd; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
807 if (!jc) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
808 jc = find_existing_chat(GJ_GC(j), who); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
809 jd = jc->gc->proto_data; |
1791
b4cc5f391133
[gaim-migrate @ 1801]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1789
diff
changeset
|
810 if (strcmp(who->resource, jc->Jid->resource)) { |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
811 remove_chat_buddy(jc->b, who->resource); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
812 return; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
813 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
814 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
815 jd->existing_chats = g_slist_remove(jd->existing_chats, jc); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
816 serv_got_chat_left(GJ_GC(j), jc->b->id); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
817 g_free(jc); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
818 } else { |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
819 if (!jc) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
820 jc = find_existing_chat(GJ_GC(j), who); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
821 if (!find_chat_buddy(jc->b, who->resource)) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
822 add_chat_buddy(jc->b, who->resource); |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
823 else if ((y = xmlnode_get_tag(p->x, "status"))) { |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
824 char buf[8192]; |
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
825 char *msg = xmlnode_get_data(y); |
1735
00f74db70f2d
[gaim-migrate @ 1745]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1724
diff
changeset
|
826 g_snprintf(buf, sizeof(buf), "%s now has status: %s", |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
827 p->from->resource, msg); |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
828 write_to_conv(jc->b, buf, WFLAG_SYSTEM, NULL, time(NULL)); |
1682
4328efeb531e
[gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1668
diff
changeset
|
829 } |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
830 } |
1359
f0c2d6b88b14
[gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1354
diff
changeset
|
831 } |
f0c2d6b88b14
[gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1354
diff
changeset
|
832 } |
1311 | 833 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
834 g_free(buddy); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
835 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
836 return; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
837 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
838 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
839 static void jabber_handles10n(gjconn j, jpacket p) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
840 { |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
841 xmlnode g; |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
842 char *Jid = xmlnode_get_attrib(p->x, "from"); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
843 char *ask = xmlnode_get_attrib(p->x, "type"); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
844 |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
845 g = xmlnode_new_tag("presence"); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
846 xmlnode_put_attrib(g, "to", Jid); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
847 if (!strcmp(ask, "subscribe")) |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
848 xmlnode_put_attrib(g, "type", "subscribed"); |
1362
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
849 else if (!strcmp(ask, "unsubscribe")) |
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
850 xmlnode_put_attrib(g, "type", "unsubscribed"); |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
851 else |
1362
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
852 return; |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
853 |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
854 gjab_send(j, g); |
1311 | 855 } |
856 | |
857 static void jabber_handleroster(gjconn j, xmlnode querynode) | |
858 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
859 xmlnode x; |
1311 | 860 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
861 x = xmlnode_get_firstchild(querynode); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
862 while (x) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
863 xmlnode g; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
864 char *Jid, *name, *sub, *ask; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
865 jid who; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
866 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
867 Jid = xmlnode_get_attrib(x, "jid"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
868 name = xmlnode_get_attrib(x, "name"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
869 sub = xmlnode_get_attrib(x, "subscription"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
870 ask = xmlnode_get_attrib(x, "ask"); |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
871 who = jid_new(j->p, Jid); |
1311 | 872 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
873 if ((g = xmlnode_get_firstchild(x))) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
874 while (g) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
875 if (strncasecmp(xmlnode_get_name(g), "group", 5) == 0) { |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
876 struct buddy *b = NULL; |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
877 char *groupname, *buddyname; |
1311 | 878 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
879 if (who->user == NULL) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
880 /* FIXME: transport */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
881 g = xmlnode_get_nextsibling(g); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
882 continue; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
883 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
884 buddyname = g_strdup_printf("%s@%s", who->user, who->server); |
1522
31c0850f9340
[gaim-migrate @ 1532]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1514
diff
changeset
|
885 groupname = xmlnode_get_data(xmlnode_get_firstchild(g)); |
31c0850f9340
[gaim-migrate @ 1532]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1514
diff
changeset
|
886 if (groupname == NULL) |
31c0850f9340
[gaim-migrate @ 1532]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1514
diff
changeset
|
887 groupname = "Buddies"; |
1758
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
888 if (strcasecmp(sub, "from") && strcasecmp(sub, "none") && |
1683
394a3a344273
[gaim-migrate @ 1693]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1682
diff
changeset
|
889 !(b = find_buddy(GJ_GC(j), buddyname))) { |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
890 debug_printf("adding buddy: %s\n", buddyname); |
1805
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1800
diff
changeset
|
891 b = add_buddy(GJ_GC(j), groupname, buddyname, |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
892 name ? name : buddyname); |
1805
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1800
diff
changeset
|
893 do_export(GJ_GC(j)); |
1758
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
894 } else if (b) { |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
895 debug_printf("updating buddy: %s/%s\n", buddyname, name); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
896 g_snprintf(b->name, sizeof(b->name), "%s", buddyname); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
897 g_snprintf(b->show, sizeof(b->show), "%s", |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
898 name ? name : buddyname); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
899 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
900 g_free(buddyname); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
901 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
902 g = xmlnode_get_nextsibling(g); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
903 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
904 } else { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
905 struct buddy *b; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
906 char *buddyname; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
907 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
908 if (who->user == NULL) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
909 /* FIXME: transport */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
910 x = xmlnode_get_nextsibling(x); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
911 continue; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
912 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
913 buddyname = g_strdup_printf("%s@%s", who->user, who->server); |
1758
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
914 if (strcasecmp(sub, "from") && strcasecmp(sub, "none") && |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
915 !(b = find_buddy(GJ_GC(j), buddyname))) { |
1864
5cb89cf24f45
[gaim-migrate @ 1874]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1854
diff
changeset
|
916 debug_printf("adding buddy: %s\n", buddyname); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
917 b = add_buddy(GJ_GC(j), "Buddies", buddyname, name ? name : Jid); |
1805
caa605e70917
[gaim-migrate @ 1815]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1800
diff
changeset
|
918 do_export(GJ_GC(j)); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
919 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
920 g_free(buddyname); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
921 } |
1311 | 922 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
923 x = xmlnode_get_nextsibling(x); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
924 } |
1331
f48cb8ddca59
[gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1316
diff
changeset
|
925 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
926 x = jutil_presnew(0, NULL, "Online"); |
1331
f48cb8ddca59
[gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1316
diff
changeset
|
927 gjab_send(j, x); |
f48cb8ddca59
[gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1316
diff
changeset
|
928 xmlnode_free(x); |
1311 | 929 } |
930 | |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
931 static void jabber_handlevcard(gjconn j, xmlnode querynode, char *from) { |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
932 char buf[1024]; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
933 char *fn, *url, *email, *nickname, *status; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
934 jid who; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
935 char *buddy; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
936 struct jabber_data *jd = GJ_GC(j)->proto_data; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
937 int at = 0; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
938 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
939 who = jid_new(j->p, from); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
940 buddy = g_strdup_printf("%s@%s", who->user, who->server); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
941 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
942 fn = xmlnode_get_tag_data(querynode, "FN"); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
943 url = xmlnode_get_tag_data(querynode, "URL"); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
944 email = xmlnode_get_tag_data(querynode, "EMAIL"); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
945 nickname = xmlnode_get_tag_data(querynode, "NICKNAME"); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
946 status = g_hash_table_lookup(jd->hash, buddy); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
947 if (!status) |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
948 status = "Online"; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
949 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
950 at = g_snprintf(buf, sizeof buf, "<B>Jabber ID:</B> %s<BR>", buddy); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
951 if (fn) |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
952 at += g_snprintf(buf + at, sizeof(buf) - at, "<B>Full Name:</B> %s<BR>", fn); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
953 if (nickname) |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
954 at += g_snprintf(buf + at, sizeof(buf) - at, "<B>Nickname:</B> %s<BR>", nickname); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
955 if (url) |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
956 at += g_snprintf(buf + at, sizeof(buf) - at, "<B>URL:</B> <A HREF=\"%s\">%s</A><BR>", |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
957 url, url); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
958 if (email) |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
959 at += g_snprintf(buf + at, sizeof(buf) - at, |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
960 "<B>Email:</B> <A HREF=\"mailto:%s\">%s</A><BR>", email, email); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
961 at += g_snprintf(buf + at, sizeof(buf) - at, "<B>Status:</B> %s\n", status); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
962 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
963 g_show_info_text(buf); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
964 g_free(buddy); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
965 } |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
966 |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
967 static void jabber_handleauthresp(gjconn j, jpacket p) |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
968 { |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
969 if (jpacket_subtype(p) == JPACKET__RESULT) { |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
970 debug_printf("auth success\n"); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
971 |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
972 account_online(GJ_GC(j)); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
973 serv_finish_login(GJ_GC(j)); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
974 |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
975 if (bud_list_cache_exists(GJ_GC(j))) |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
976 do_import(NULL, GJ_GC(j)); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
977 |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
978 ((struct jabber_data *)GJ_GC(j)->proto_data)->did_import = TRUE; |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
979 |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
980 gjab_reqroster(j); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
981 } else { |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
982 xmlnode xerr; |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
983 char *errmsg = NULL; |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
984 int errcode = 0; |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
985 |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
986 debug_printf("auth failed\n"); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
987 xerr = xmlnode_get_tag(p->x, "error"); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
988 if (xerr) { |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
989 char msg[BUF_LONG]; |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
990 errmsg = xmlnode_get_data(xerr); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
991 if (xmlnode_get_attrib(xerr, "code")) { |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
992 errcode = atoi(xmlnode_get_attrib(xerr, "code")); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
993 g_snprintf(msg, sizeof(msg), "Error %d: %s", errcode, errmsg); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
994 } else |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
995 g_snprintf(msg, sizeof(msg), "%s", errmsg); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
996 hide_login_progress(GJ_GC(j), msg); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
997 } else { |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
998 hide_login_progress(GJ_GC(j), "Unknown login error"); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
999 } |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1000 |
1865
8d758ff5957e
[gaim-migrate @ 1875]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1001 signoff(GJ_GC(j)); |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1002 } |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1003 } |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1004 |
1789
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1005 static void jabber_handleversion(gjconn j, xmlnode iqnode) { |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1006 xmlnode querynode, x; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1007 char *id, *from; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1008 char os[1024]; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1009 struct utsname osinfo; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1010 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1011 uname(&osinfo); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1012 g_snprintf(os, sizeof os, "%s %s %s", osinfo.sysname, osinfo.release, osinfo.machine); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1013 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1014 id = xmlnode_get_attrib(iqnode, "id"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1015 from = xmlnode_get_attrib(iqnode, "from"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1016 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1017 x = jutil_iqnew(JPACKET__RESULT, NS_VERSION); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1018 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1019 xmlnode_put_attrib(x, "to", from); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1020 xmlnode_put_attrib(x, "id", id); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1021 querynode = xmlnode_get_tag(x, "query"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1022 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "name"), PACKAGE, -1); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1023 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "version"), VERSION, -1); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1024 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "os"), os, -1); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1025 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1026 gjab_send(j, x); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1027 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1028 xmlnode_free(x); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1029 } |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1030 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1031 static void jabber_handletime(gjconn j, xmlnode iqnode) { |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1032 xmlnode querynode, x; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1033 char *id, *from; |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1034 time_t now_t; |
1789
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1035 struct tm *now; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1036 char buf[1024]; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1037 |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1038 time(&now_t); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1039 now = localtime(&now_t); |
1789
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1040 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1041 id = xmlnode_get_attrib(iqnode, "id"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1042 from = xmlnode_get_attrib(iqnode, "from"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1043 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1044 x = jutil_iqnew(JPACKET__RESULT, NS_TIME); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1045 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1046 xmlnode_put_attrib(x, "to", from); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1047 xmlnode_put_attrib(x, "id", id); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1048 querynode = xmlnode_get_tag(x, "query"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1049 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1050 strftime(buf, 1024, "%Y%m%dT%T", now); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1051 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "utc"), buf, -1); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1052 strftime(buf, 1024, "%Z", now); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1053 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "tz"), buf, -1); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1054 strftime(buf, 1024, "%d %b %Y %T", now); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1055 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "display"), buf, -1); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1056 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1057 gjab_send(j, x); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1058 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1059 xmlnode_free(x); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1060 } |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1061 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1062 static void jabber_handlelast(gjconn j, xmlnode iqnode) { |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1063 xmlnode x, querytag; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1064 char *id, *from; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1065 struct jabber_data *jd = GJ_GC(j)->proto_data; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1066 char idle_time[32]; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1067 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1068 id = xmlnode_get_attrib(iqnode, "id"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1069 from = xmlnode_get_attrib(iqnode, "from"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1070 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1071 x = jutil_iqnew(JPACKET__RESULT, "jabber:iq:last"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1072 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1073 xmlnode_put_attrib(x, "to", from); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1074 xmlnode_put_attrib(x, "id", id); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1075 querytag = xmlnode_get_tag(x, "query"); |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1076 g_snprintf(idle_time, sizeof idle_time, "%ld", jd->idle ? time(NULL) - jd->idle : 0); |
1789
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1077 xmlnode_put_attrib(querytag, "seconds", idle_time); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1078 |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1079 gjab_send(j, x); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1080 xmlnode_free(x); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1081 } |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1082 |
1311 | 1083 static void jabber_handlepacket(gjconn j, jpacket p) |
1084 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1085 switch (p->type) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1086 case JPACKET_MESSAGE: |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1087 jabber_handlemessage(j, p); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1088 break; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1089 case JPACKET_PRESENCE: |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1090 jabber_handlepresence(j, p); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1091 break; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1092 case JPACKET_IQ: |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1093 debug_printf("jpacket_subtype: %d\n", jpacket_subtype(p)); |
1311 | 1094 |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1095 if (xmlnode_get_attrib(p->x, "id") && (strcmp(xmlnode_get_attrib(p->x, "id"), IQID_AUTH) == 0)) { |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1096 jabber_handleauthresp(j, p); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1097 break; /* I'm not sure if you like this style, Eric. */ |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1098 } |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1099 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1100 if (jpacket_subtype(p) == JPACKET__SET) { |
1684
89c19002e73d
[gaim-migrate @ 1694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1683
diff
changeset
|
1101 } else if (jpacket_subtype(p) == JPACKET__GET) { |
1789
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1102 xmlnode querynode; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1103 querynode = xmlnode_get_tag(p->x, "query"); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1104 if(NSCHECK(querynode, NS_VERSION)) { |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1105 jabber_handleversion(j, p->x); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1106 } else if (NSCHECK(querynode, NS_TIME)) { |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1107 jabber_handletime(j, p->x); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1108 } else if (NSCHECK(querynode, "jabber:iq:last")) { |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1109 jabber_handlelast(j, p->x); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1110 } |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1111 } else if (jpacket_subtype(p) == JPACKET__RESULT) { |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1112 xmlnode querynode, vcard; |
1362
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
1113 char *xmlns, *from; |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1114 |
1362
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
1115 from = xmlnode_get_attrib(p->x, "from"); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1116 querynode = xmlnode_get_tag(p->x, "query"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1117 xmlns = xmlnode_get_attrib(querynode, "xmlns"); |
1870
28921530e20b
[gaim-migrate @ 1880]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1866
diff
changeset
|
1118 vcard = xmlnode_get_tag(p->x, "vCard"); |
1311 | 1119 |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1120 if (NSCHECK(querynode, NS_ROSTER)) { |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1121 jabber_handleroster(j, querynode); |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1122 } else if (NSCHECK(querynode, NS_VCARD)) { |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1123 jabber_handlevcard(j, querynode, from); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1124 } else if(vcard) { |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1125 jabber_handlevcard(j, vcard, from); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1126 } else { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1127 /* debug_printf("jabber:iq:query: %s\n", xmlns); */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1128 } |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1129 |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1130 } else if (jpacket_subtype(p) == JPACKET__ERROR) { |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1131 xmlnode xerr; |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1132 char *from, *errmsg = NULL; |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1133 int errcode = 0; |
1311 | 1134 |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1135 from = xmlnode_get_attrib(p->x, "from"); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1136 xerr = xmlnode_get_tag(p->x, "error"); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1137 if (xerr) { |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1138 errmsg = xmlnode_get_data(xerr); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1139 if (xmlnode_get_attrib(xerr, "code")) |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1140 errcode = atoi(xmlnode_get_attrib(xerr, "code")); |
1707
5417bf0c8e28
[gaim-migrate @ 1717]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1704
diff
changeset
|
1141 } |
1311 | 1142 |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1143 from = g_strdup_printf("Error %d (%s)", errcode, from); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1144 do_error_dialog(errmsg, from); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1145 g_free(from); |
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1146 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1147 } |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1148 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1149 break; |
1800
a94491b828ef
[gaim-migrate @ 1810]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1795
diff
changeset
|
1150 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1151 case JPACKET_S10N: |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1152 jabber_handles10n(j, p); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1153 break; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1154 default: |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1155 debug_printf("jabber: packet type %d (%s)\n", p->type, xmlnode2str(p->x)); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1156 } |
1311 | 1157 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1158 xmlnode_free(p->x); |
1311 | 1159 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1160 return; |
1311 | 1161 } |
1162 | |
1163 static void jabber_handlestate(gjconn j, int state) | |
1164 { | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1165 switch (state) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1166 case JCONN_STATE_OFF: |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1167 hide_login_progress(GJ_GC(j), "Unable to connect"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1168 signoff(GJ_GC(j)); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1169 break; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1170 case JCONN_STATE_CONNECTED: |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1171 set_login_progress(GJ_GC(j), 3, "Connected"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1172 break; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1173 case JCONN_STATE_ON: |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1174 set_login_progress(GJ_GC(j), 5, "Logging in..."); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1175 gjab_auth(j); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1176 break; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1177 default: |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1178 debug_printf("state change: %d\n", state); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1179 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1180 return; |
1311 | 1181 } |
1182 | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1183 static void jabber_login(struct aim_user *user) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1184 { |
1311 | 1185 struct gaim_connection *gc = new_gaim_conn(user); |
1186 struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1); | |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1187 char *loginname = create_valid_jid(user->username, DEFAULT_SERVER, "GAIM"); |
1311 | 1188 |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1189 jd->hash = g_hash_table_new(g_str_hash, g_str_equal); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1190 |
1311 | 1191 set_login_progress(gc, 1, "Connecting"); |
1192 | |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1193 if (!(jd->jc = gjab_new(loginname, user->password, gc))) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1194 g_free(loginname); |
1311 | 1195 debug_printf("jabber: unable to connect (jab_new failed)\n"); |
1196 hide_login_progress(gc, "Unable to connect"); | |
1197 signoff(gc); | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1198 return; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1199 } |
1311 | 1200 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1201 g_free(loginname); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1202 gjab_state_handler(jd->jc, jabber_handlestate); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1203 gjab_packet_handler(jd->jc, jabber_handlepacket); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1204 gjab_start(jd->jc); |
1311 | 1205 } |
1206 | |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1207 static gboolean jabber_destroy_hash(gpointer key, gpointer val, gpointer data) { |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1208 g_free(key); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1209 g_free(val); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1210 return TRUE; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1211 } |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1212 |
1865
8d758ff5957e
[gaim-migrate @ 1875]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1213 static gboolean jabber_free(gpointer data) |
8d758ff5957e
[gaim-migrate @ 1875]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1214 { |
8d758ff5957e
[gaim-migrate @ 1875]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1215 gjab_delete(data); |
8d758ff5957e
[gaim-migrate @ 1875]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1216 return FALSE; |
8d758ff5957e
[gaim-migrate @ 1875]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1217 } |
8d758ff5957e
[gaim-migrate @ 1875]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1218 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1219 static void jabber_close(struct gaim_connection *gc) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1220 { |
1312
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
1221 struct jabber_data *jd = gc->proto_data; |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1222 g_hash_table_foreach_remove(jd->hash, jabber_destroy_hash, NULL); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1223 g_hash_table_destroy(jd->hash); |
1312
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
1224 gdk_input_remove(gc->inpa); |
1865
8d758ff5957e
[gaim-migrate @ 1875]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1225 close(jd->jc->fd); |
8d758ff5957e
[gaim-migrate @ 1875]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1864
diff
changeset
|
1226 gtk_timeout_add(50, jabber_free, jd->jc); |
1666
8b0c165a33f4
[gaim-migrate @ 1676]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1665
diff
changeset
|
1227 jd->jc = NULL; |
1312
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
1228 g_free(jd); |
1624
12bd198b6721
[gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1611
diff
changeset
|
1229 gc->proto_data = NULL; |
1311 | 1230 } |
1231 | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1232 static void jabber_send_im(struct gaim_connection *gc, char *who, char *message, int away) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1233 { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1234 xmlnode x, y; |
1316
d5069ad0b6b1
[gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1315
diff
changeset
|
1235 char *realwho; |
d5069ad0b6b1
[gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1315
diff
changeset
|
1236 gjconn j = ((struct jabber_data *)gc->proto_data)->jc; |
1311 | 1237 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1238 if (!who || !message) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1239 return; |
1311 | 1240 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1241 x = xmlnode_new_tag("message"); |
1316
d5069ad0b6b1
[gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1315
diff
changeset
|
1242 if (!strchr(who, '@')) |
d5069ad0b6b1
[gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1315
diff
changeset
|
1243 realwho = g_strdup_printf("%s@%s", who, j->user->server); |
d5069ad0b6b1
[gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1315
diff
changeset
|
1244 else |
d5069ad0b6b1
[gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1315
diff
changeset
|
1245 realwho = g_strdup(who); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1246 xmlnode_put_attrib(x, "to", realwho); |
1316
d5069ad0b6b1
[gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1315
diff
changeset
|
1247 g_free(realwho); |
1311 | 1248 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1249 xmlnode_put_attrib(x, "type", "chat"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1250 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1251 if (message && strlen(message)) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1252 y = xmlnode_insert_tag(x, "body"); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1253 xmlnode_insert_cdata(y, message, -1); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1254 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1255 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1256 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1257 xmlnode_free(x); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1258 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1259 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1260 static void jabber_add_buddy(struct gaim_connection *gc, char *name) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1261 { |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1262 xmlnode x, y; |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1263 char *realwho; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1264 gjconn j = ((struct jabber_data *)gc->proto_data)->jc; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1265 |
1362
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
1266 if (!((struct jabber_data *)gc->proto_data)->did_import) |
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
1267 return; |
3cea00ca7a34
[gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1359
diff
changeset
|
1268 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1269 if (!name) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1270 return; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1271 |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1272 if (!strcmp(gc->username, name)) |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1273 return; |
1311 | 1274 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1275 if (!strchr(name, '@')) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1276 realwho = g_strdup_printf("%s@%s", name, j->user->server); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1277 else { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1278 jid who = jid_new(j->p, name); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1279 if (who->user == NULL) { |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1280 /* FIXME: transport */ |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1281 return; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1282 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1283 realwho = g_strdup_printf("%s@%s", who->user, who->server); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1284 } |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1285 |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1286 x = jutil_iqnew(JPACKET__SET, NS_ROSTER); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1287 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item"); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1288 xmlnode_put_attrib(y, "jid", realwho); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1289 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x); |
1363
b454b1d084ce
[gaim-migrate @ 1373]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1362
diff
changeset
|
1290 xmlnode_free(x); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1291 |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1292 x = xmlnode_new_tag("presence"); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1293 xmlnode_put_attrib(x, "to", realwho); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1294 xmlnode_put_attrib(x, "type", "subscribe"); |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1295 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1296 |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1297 g_free(realwho); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1298 } |
1311 | 1299 |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1300 static void jabber_remove_buddy(struct gaim_connection *gc, char *name) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1301 { |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1302 xmlnode x, y; |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1303 char *realwho; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1304 gjconn j = ((struct jabber_data *)gc->proto_data)->jc; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1305 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1306 if (!name) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1307 return; |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1308 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1309 if (!strchr(name, '@')) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1310 realwho = g_strdup_printf("%s@%s", name, j->user->server); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1311 else |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1312 realwho = g_strdup(name); |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1313 |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1314 x = jutil_iqnew(JPACKET__SET, NS_ROSTER); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1315 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item"); |
1353
f6a8bca11766
[gaim-migrate @ 1363]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1349
diff
changeset
|
1316 xmlnode_put_attrib(y, "jid", realwho); |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1317 xmlnode_put_attrib(y, "subscription", "remove"); |
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1318 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1319 |
1349
9e647319dd63
[gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1347
diff
changeset
|
1320 g_free(realwho); |
1363
b454b1d084ce
[gaim-migrate @ 1373]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1362
diff
changeset
|
1321 xmlnode_free(x); |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1322 } |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1323 |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1324 static char **jabber_list_icon(int uc) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
1325 { |
1354
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1326 switch (uc) { |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1327 case UC_AWAY: |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1328 return available_away_xpm; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1329 case UC_CHAT: |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1330 return available_chat_xpm; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1331 case UC_XA: |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1332 return available_xa_xpm; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1333 case UC_DND: |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1334 return available_dnd_xpm; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1335 default: |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1336 return available_xpm; |
6b0a7cea1dd1
[gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1353
diff
changeset
|
1337 } |
1311 | 1338 } |
1339 | |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1340 static void jabber_join_chat(struct gaim_connection *gc, int exch, char *name) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1341 { |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1342 xmlnode x; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1343 char *realwho; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1344 gjconn j = ((struct jabber_data *)gc->proto_data)->jc; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1345 GSList *pc = ((struct jabber_data *)gc->proto_data)->pending_chats; |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1346 struct jabber_chat *jc; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1347 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1348 if (!name) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1349 return; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1350 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1351 jc = g_new0(struct jabber_chat, 1); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1352 realwho = create_valid_jid(name, DEFAULT_GROUPCHAT, j->user->user); |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1353 jc->Jid = jid_new(j->p, realwho); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1354 jc->gc = gc; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1355 debug_printf("%s\n", realwho); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1356 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1357 x = jutil_presnew(0, realwho, NULL); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1358 gjab_send(j, x); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1359 xmlnode_free(x); |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1360 g_free(realwho); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1361 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1362 ((struct jabber_data *)gc->proto_data)->pending_chats = g_slist_append(pc, jc); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1363 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1364 |
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1365 static void jabber_chat_invite(struct gaim_connection *gc, int id, char *message, char *name) |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1366 { |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1367 xmlnode x, y; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1368 GSList *bcs = gc->buddy_chats; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1369 struct conversation *b; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1370 struct jabber_data *jd = gc->proto_data; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1371 gjconn j = jd->jc; |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1372 struct jabber_chat *jc; |
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1373 char *realwho, *subject; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1374 |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1375 if (!name) |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1376 return; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1377 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1378 /* find which chat we're inviting to */ |
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1379 while (bcs) { |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1380 b = bcs->data; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1381 if (id == b->id) |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1382 break; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1383 bcs = bcs->next; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1384 } |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1385 if (!bcs) |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1386 return; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1387 |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1388 bcs = jd->existing_chats; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1389 while (bcs) { |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1390 jc = bcs->data; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1391 if (jc->b == b) |
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1392 break; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1393 bcs = bcs->next; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1394 } |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1395 if (!bcs) |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1396 return; |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1397 |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1398 x = xmlnode_new_tag("message"); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1399 if (!strchr(name, '@')) |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1400 realwho = g_strdup_printf("%s@%s", name, j->user->server); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1401 else |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1402 realwho = g_strdup(name); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1403 xmlnode_put_attrib(x, "to", realwho); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1404 g_free(realwho); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1405 |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1406 y = xmlnode_insert_tag(x, "x"); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1407 xmlnode_put_attrib(y, "xmlns", "jabber:x:conference"); |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1408 subject = g_strdup_printf("%s@%s", jc->Jid->user, jc->Jid->server); |
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1409 xmlnode_put_attrib(y, "jid", subject); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1410 g_free(subject); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1411 |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1412 if (message && strlen(message)) { |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1413 y = xmlnode_insert_tag(x, "body"); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1414 xmlnode_insert_cdata(y, message, -1); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1415 } |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1416 |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1417 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1418 xmlnode_free(x); |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1419 } |
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
1420 |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1421 static void jabber_chat_leave(struct gaim_connection *gc, int id) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1422 { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1423 GSList *bcs = gc->buddy_chats; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1424 struct conversation *b; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1425 struct jabber_data *jd = gc->proto_data; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1426 gjconn j = jd->jc; |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1427 struct jabber_chat *jc; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1428 char *realwho; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1429 xmlnode x; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1430 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1431 while (bcs) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1432 b = bcs->data; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1433 if (id == b->id) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1434 break; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1435 bcs = bcs->next; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1436 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1437 if (!bcs) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1438 return; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1439 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1440 bcs = jd->existing_chats; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1441 while (bcs) { |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1442 jc = bcs->data; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1443 if (jc->b == b) |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1444 break; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1445 bcs = bcs->next; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1446 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1447 if (!bcs) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1448 return; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1449 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1450 realwho = g_strdup_printf("%s@%s", jc->Jid->user, jc->Jid->server); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1451 x = jutil_presnew(0, realwho, NULL); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1452 g_free(realwho); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1453 xmlnode_put_attrib(x, "type", "unavailable"); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1454 gjab_send(j, x); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1455 xmlnode_free(x); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1456 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1457 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1458 static void jabber_chat_send(struct gaim_connection *gc, int id, char *message) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1459 { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1460 GSList *bcs = gc->buddy_chats; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1461 struct conversation *b; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1462 struct jabber_data *jd = gc->proto_data; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1463 xmlnode x, y; |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1464 struct jabber_chat *jc; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1465 char *chatname; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1466 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1467 while (bcs) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1468 b = bcs->data; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1469 if (id == b->id) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1470 break; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1471 bcs = bcs->next; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1472 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1473 if (!bcs) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1474 return; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1475 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1476 bcs = jd->existing_chats; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1477 while (bcs) { |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1478 jc = bcs->data; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1479 if (jc->b == b) |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1480 break; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1481 bcs = bcs->next; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1482 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1483 if (!bcs) |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1484 return; |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1485 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1486 x = xmlnode_new_tag("message"); |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1487 xmlnode_put_attrib(x, "from", jid_full(jc->Jid)); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1488 chatname = g_strdup_printf("%s@%s", jc->Jid->user, jc->Jid->server); |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1489 xmlnode_put_attrib(x, "to", chatname); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1490 g_free(chatname); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1491 xmlnode_put_attrib(x, "type", "groupchat"); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1492 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1493 if (message && strlen(message)) { |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1494 y = xmlnode_insert_tag(x, "body"); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1495 xmlnode_insert_cdata(y, message, -1); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1496 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1497 |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1498 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1499 xmlnode_free(x); |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1500 } |
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
1501 |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1502 static void jabber_chat_whisper(struct gaim_connection *gc, int id, char *who, char *message) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1503 { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1504 GSList *bcs = gc->buddy_chats; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1505 struct conversation *b; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1506 struct jabber_data *jd = gc->proto_data; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1507 xmlnode x, y; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1508 struct jabber_chat *jc; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1509 char *chatname; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1510 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1511 while (bcs) { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1512 b = bcs->data; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1513 if (id == b->id) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1514 break; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1515 bcs = bcs->next; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1516 } |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1517 if (!bcs) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1518 return; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1519 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1520 bcs = jd->existing_chats; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1521 while (bcs) { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1522 jc = bcs->data; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1523 if (jc->b == b) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1524 break; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1525 bcs = bcs->next; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1526 } |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1527 if (!bcs) |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1528 return; |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1529 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1530 x = xmlnode_new_tag("message"); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1531 xmlnode_put_attrib(x, "from", jid_full(jc->Jid)); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1532 chatname = g_strdup_printf("%s@%s/%s", jc->Jid->user, jc->Jid->server, who); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1533 xmlnode_put_attrib(x, "to", chatname); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1534 g_free(chatname); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1535 xmlnode_put_attrib(x, "type", "normal"); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1536 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1537 if (message && strlen(message)) { |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1538 y = xmlnode_insert_tag(x, "body"); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1539 xmlnode_insert_cdata(y, message, -1); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1540 } |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1541 |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1542 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1543 xmlnode_free(x); |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1544 } |
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
1545 |
1642
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1546 static GtkWidget *newname = NULL; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1547 static GtkWidget *newpass1 = NULL; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1548 static GtkWidget *newpass2 = NULL; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1549 static GtkWidget *newserv = NULL; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1550 static jconn regjconn = NULL; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1551 static int reginpa = 0; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1552 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1553 static void newdes() |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1554 { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1555 newname = newpass1 = newpass2 = newserv = NULL; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1556 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1557 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1558 static void jabber_draw_new_user(GtkWidget *box) |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1559 { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1560 GtkWidget *hbox; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1561 GtkWidget *label; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1562 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1563 if (newname) |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1564 return; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1565 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1566 label = gtk_label_new("Enter your name, password, and server to register on. If you " |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1567 "already have a Jabber account and do not need to register one, " |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1568 "use the Account Editor to add it to your list of accounts."); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1569 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1570 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1571 gtk_widget_show(label); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1572 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1573 hbox = gtk_hbox_new(FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1574 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1575 gtk_widget_show(hbox); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1576 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1577 label = gtk_label_new("Username:"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1578 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1579 gtk_widget_show(label); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1580 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1581 newname = gtk_entry_new(); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1582 gtk_box_pack_end(GTK_BOX(hbox), newname, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1583 gtk_signal_connect(GTK_OBJECT(newname), "destroy", GTK_SIGNAL_FUNC(newdes), NULL); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1584 gtk_widget_show(newname); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1585 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1586 hbox = gtk_hbox_new(FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1587 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1588 gtk_widget_show(hbox); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1589 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1590 label = gtk_label_new("Password:"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1591 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1592 gtk_widget_show(label); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1593 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1594 newpass1 = gtk_entry_new(); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1595 gtk_box_pack_end(GTK_BOX(hbox), newpass1, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1596 gtk_entry_set_visibility(GTK_ENTRY(newpass1), FALSE); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1597 gtk_widget_show(newpass1); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1598 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1599 hbox = gtk_hbox_new(FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1600 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1601 gtk_widget_show(hbox); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1602 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1603 label = gtk_label_new("Confirm:"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1604 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1605 gtk_widget_show(label); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1606 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1607 newpass2 = gtk_entry_new(); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1608 gtk_box_pack_end(GTK_BOX(hbox), newpass2, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1609 gtk_entry_set_visibility(GTK_ENTRY(newpass2), FALSE); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1610 gtk_widget_show(newpass2); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1611 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1612 hbox = gtk_hbox_new(FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1613 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1614 gtk_widget_show(hbox); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1615 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1616 label = gtk_label_new("Server:"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1617 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1618 gtk_widget_show(label); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1619 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1620 newserv = gtk_entry_new(); |
1644
fb1741bc3bd0
[gaim-migrate @ 1654]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1642
diff
changeset
|
1621 gtk_entry_set_text(GTK_ENTRY(newserv), "jabber.org"); |
1642
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1622 gtk_box_pack_end(GTK_BOX(hbox), newserv, FALSE, FALSE, 5); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1623 gtk_widget_show(newserv); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1624 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1625 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1626 static void regstate(jconn j, int state) |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1627 { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1628 static int catch = 0; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1629 switch (state) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1630 case JCONN_STATE_OFF: |
1696
c6390c52caca
[gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1688
diff
changeset
|
1631 gdk_input_remove(reginpa); |
c6390c52caca
[gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1688
diff
changeset
|
1632 reginpa = 0; |
c6390c52caca
[gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1688
diff
changeset
|
1633 jab_delete(j); |
1642
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1634 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1635 case JCONN_STATE_CONNECTED: |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1636 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1637 case JCONN_STATE_ON: |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1638 if (catch) |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1639 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1640 catch = 1; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1641 jab_reg(regjconn); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1642 catch = 0; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1643 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1644 case JCONN_STATE_AUTH: |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1645 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1646 default: |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1647 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1648 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1649 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1650 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1651 static void regpacket(jconn j, jpacket p) |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1652 { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1653 static int here = 0; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1654 switch (p->type) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1655 case JPACKET_MESSAGE: |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1656 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1657 case JPACKET_PRESENCE: |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1658 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1659 case JPACKET_IQ: |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1660 if (jpacket_subtype(p) == JPACKET__RESULT) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1661 xmlnode x, y, z; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1662 char *user, *id; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1663 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1664 if (here == 2) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1665 struct aim_user *u; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1666 user = g_strdup(jid_full(j->user)); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1667 regjconn = NULL; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1668 here = 0; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1669 u = new_user(user, PROTO_JABBER, OPT_USR_REM_PASS); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1670 g_free(user); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1671 g_snprintf(u->password, sizeof(u->password), "%s", j->pass); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1672 save_prefs(); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1673 xmlnode_free(p->x); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1674 do_error_dialog("Registration successful! Your account has been" |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1675 " added to the Account Editor.", "Jabber " |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1676 "Registration"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1677 gtk_entry_set_text(GTK_ENTRY(newname), ""); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1678 gtk_entry_set_text(GTK_ENTRY(newpass1), ""); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1679 gtk_entry_set_text(GTK_ENTRY(newpass2), ""); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1680 return; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1681 } else if (here == 1) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1682 x = jutil_iqnew(JPACKET__SET, NS_AUTH); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1683 here = 2; |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1684 } else { /* here == 0 */ |
1642
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1685 here = 1; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1686 x = jutil_iqnew(JPACKET__GET, NS_AUTH); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1687 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1688 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1689 id = jab_getid(j); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1690 xmlnode_put_attrib(x, "id", id); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1691 y = xmlnode_get_tag(x, "query"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1692 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1693 user = j->user->user; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1694 if (user) |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1695 { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1696 z = xmlnode_insert_tag(y, "username"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1697 xmlnode_insert_cdata(z, user, -1); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1698 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1699 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1700 if (here == 2) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1701 z = xmlnode_insert_tag(y, "resource"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1702 xmlnode_insert_cdata(z, j->user->resource, -1); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1703 z = xmlnode_insert_tag(y, "password"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1704 xmlnode_insert_cdata(z, j->pass, -1); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1705 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1706 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1707 jab_send(j, x); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1708 xmlnode_free(x); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1709 } else if (jpacket_subtype(p) == JPACKET__ERROR) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1710 xmlnode x = xmlnode_get_tag(p->x, "error"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1711 if (x) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1712 char buf[8192]; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1713 g_snprintf(buf, sizeof(buf), "Registration failed: %d %s", |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1714 atoi(xmlnode_get_attrib(x, "code")), |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1715 xmlnode_get_data(xmlnode_get_firstchild(x))); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1716 do_error_dialog(buf, "Jabber Registration"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1717 } else { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1718 do_error_dialog("Registration failed", "Jabber Registration"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1719 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1720 regjconn = NULL; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1721 xmlnode_free(p->x); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1722 here = 0; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1723 return; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1724 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1725 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1726 case JPACKET_S10N: |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1727 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1728 default: |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1729 break; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1730 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1731 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1732 xmlnode_free(p->x); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1733 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1734 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1735 static void regjcall(gpointer data, gint source, GdkInputCondition cond) |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1736 { |
1696
c6390c52caca
[gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1688
diff
changeset
|
1737 gjab_recv((gjconn)regjconn); |
1642
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1738 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1739 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1740 static void jabber_do_new_user() |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1741 { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1742 char *name, *pass1, *pass2, *serv; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1743 char *user; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1744 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1745 if (!newname || regjconn) |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1746 return; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1747 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1748 pass1 = gtk_entry_get_text(GTK_ENTRY(newpass1)); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1749 pass2 = gtk_entry_get_text(GTK_ENTRY(newpass2)); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1750 if (pass1[0] == 0 || pass2[0] == 0) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1751 do_error_dialog("Please enter the same valid password in both password entry boxes", |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1752 "Registration error"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1753 return; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1754 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1755 if (strcmp(pass1, pass2)) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1756 do_error_dialog("Mismatched passwords, please verify that both passwords are the same", |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1757 "Registration error"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1758 return; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1759 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1760 name = gtk_entry_get_text(GTK_ENTRY(newname)); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1761 serv = gtk_entry_get_text(GTK_ENTRY(newserv)); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1762 if (name[0] == 0 || serv[0] == 0) { |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1763 do_error_dialog("Please enter a valid username and server", "Registration error"); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1764 return; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1765 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1766 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1767 user = g_strdup_printf("%s@%s/GAIM", name, serv); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1768 regjconn = jab_new(user, pass1); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1769 g_free(user); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1770 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1771 jab_state_handler(regjconn, regstate); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1772 jab_packet_handler(regjconn, regpacket); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1773 |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1774 jab_start(regjconn); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1775 reginpa = gdk_input_add(jab_getfd(regjconn), GDK_INPUT_READ, regjcall, NULL); |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1776 } |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
1777 |
1713
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1778 static char *jabber_normalize(const char *s) |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1779 { |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1780 static char buf[BUF_LEN]; |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1781 char *t, *u; |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1782 int x = 0; |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1783 |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1784 g_return_val_if_fail((s != NULL), NULL); |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1785 |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1786 u = t = g_strdup(s); |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1787 |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1788 g_strdown(t); |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1789 |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1790 while (*t && (x < BUF_LEN - 1)) { |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1791 if (*t != ' ') |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1792 buf[x++] = *t; |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1793 t++; |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1794 } |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1795 buf[x] = '\0'; |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1796 g_free(u); |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1797 |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1798 if (!strchr(buf, '@')) { |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1799 strcat(buf, "@jabber.org"); /* this isn't always right, but eh */ |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1800 } else if ((u = strchr(strchr(buf, '@'), '/')) != NULL) { |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1801 *u = '\0'; |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1802 } |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1803 |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1804 return buf; |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1805 } |
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
1806 |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1807 static void jabber_get_info(struct gaim_connection *gc, char *who) { |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1808 xmlnode x; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1809 char *id; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1810 struct jabber_data *jd = gc->proto_data; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1811 gjconn j = jd->jc; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1812 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1813 x = jutil_iqnew(JPACKET__GET, NS_VCARD); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1814 xmlnode_put_attrib(x, "to", who); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1815 id = gjab_getid(j); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1816 xmlnode_put_attrib(x, "id", id); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1817 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1818 gjab_send(j, x); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1819 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1820 xmlnode_free(x); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1821 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1822 } |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1823 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1824 static void jabber_info(GtkObject *obj, char *who) { |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1825 serv_get_info(gtk_object_get_user_data(obj), who); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1826 } |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1827 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1828 static void jabber_buddy_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) { |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1829 GtkWidget *button; |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1830 |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1831 button = gtk_menu_item_new_with_label(_("Get Info")); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1832 gtk_signal_connect(GTK_OBJECT(button), "activate", |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1833 GTK_SIGNAL_FUNC(jabber_info), who); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1834 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1835 gtk_menu_append(GTK_MENU(menu), button); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1836 gtk_widget_show(button); |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1837 } |
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
1838 |
1758
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1839 static GList *jabber_away_states() { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1840 GList *m = NULL; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1841 |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1842 m = g_list_append(m, "Online"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1843 m = g_list_append(m, "Chatty"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1844 m = g_list_append(m, "Away"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1845 m = g_list_append(m, "Extended Away"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1846 m = g_list_append(m, "Do Not Disturb"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1847 |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1848 return m; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1849 } |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1850 |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1851 static void jabber_set_away(struct gaim_connection *gc, char *state, char *message) |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1852 { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1853 xmlnode x, y; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1854 struct jabber_data *jd = gc->proto_data; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1855 gjconn j = jd->jc; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1856 |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1857 gc->away = NULL; /* never send an auto-response */ |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1858 |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1859 x = xmlnode_new_tag("presence"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1860 |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1861 if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1862 /* oh goody. Gaim is telling us what to do. */ |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1863 if (message) { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1864 /* Gaim wants us to be away */ |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1865 y = xmlnode_insert_tag(x, "show"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1866 xmlnode_insert_cdata(y, "away", -1); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1867 y = xmlnode_insert_tag(x, "status"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1868 xmlnode_insert_cdata(y, message, -1); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1869 gc->away = ""; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1870 } else { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1871 /* Gaim wants us to not be away */ |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1872 /* but for Jabber, we can just send presence with no other information. */ |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1873 } |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1874 } else { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1875 /* state is one of our own strings. it won't be NULL. */ |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1876 if (!strcmp(state, "Online")) { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1877 /* once again, we don't have to put anything here */ |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1878 } else if (!strcmp(state, "Chatty")) { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1879 y = xmlnode_insert_tag(x, "show"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1880 xmlnode_insert_cdata(y, "chat", -1); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1881 } else if (!strcmp(state, "Away")) { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1882 y = xmlnode_insert_tag(x, "show"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1883 xmlnode_insert_cdata(y, "away", -1); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1884 gc->away = ""; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1885 } else if (!strcmp(state, "Extended Away")) { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1886 y = xmlnode_insert_tag(x, "show"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1887 xmlnode_insert_cdata(y, "xa", -1); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1888 gc->away = ""; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1889 } else if (!strcmp(state, "Do Not Disturb")) { |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1890 y = xmlnode_insert_tag(x, "show"); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1891 xmlnode_insert_cdata(y, "dnd", -1); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1892 gc->away = ""; |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1893 } |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1894 } |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1895 |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1896 gjab_send(j, x); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1897 xmlnode_free(x); |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1898 } |
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
1899 |
1789
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1900 static void jabber_set_idle(struct gaim_connection *gc, int idle) { |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1901 struct jabber_data *jd = (struct jabber_data *)gc->proto_data; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1902 debug_printf("jabber_set_idle: setting idle %i\n", idle); |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1903 jd->idle = idle ? time(NULL) - idle : idle; |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1904 } |
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
1905 |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1906 static void jabber_print_option(GtkEntry *entry, struct aim_user *user) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1907 { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1908 int entrynum; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1909 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1910 entrynum = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1911 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1912 if (entrynum == USEROPT_PROXYSERV) { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1913 g_snprintf(user->proto_opt[USEROPT_PROXYSERV], |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1914 sizeof(user->proto_opt[USEROPT_PROXYSERV]), "%s", gtk_entry_get_text(entry)); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1915 } else if (entrynum == USEROPT_PROXYPORT) { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1916 g_snprintf(user->proto_opt[USEROPT_PROXYPORT], |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1917 sizeof(user->proto_opt[USEROPT_PROXYPORT]), "%s", gtk_entry_get_text(entry)); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1918 } else if (entrynum == USEROPT_USER) { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1919 g_snprintf(user->proto_opt[USEROPT_USER], |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1920 sizeof(user->proto_opt[USEROPT_USER]), "%s", gtk_entry_get_text(entry)); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1921 } else if (entrynum == USEROPT_PASS) { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1922 g_snprintf(user->proto_opt[USEROPT_PASS], |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1923 sizeof(user->proto_opt[USEROPT_PASS]), "%s", gtk_entry_get_text(entry)); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1924 } |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1925 } |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1926 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1927 static void jabber_print_optionrad(GtkRadioButton *entry, struct aim_user *user) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1928 { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1929 int entrynum; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1930 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1931 entrynum = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1932 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1933 g_snprintf(user->proto_opt[USEROPT_PROXYTYPE], |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1934 sizeof(user->proto_opt[USEROPT_PROXYTYPE]), "%d", entrynum); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1935 } |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1936 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1937 static void jabber_user_opts(GtkWidget *book, struct aim_user *user) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1938 { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1939 /* so here, we create the new notebook page */ |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1940 GtkWidget *vbox; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1941 GtkWidget *hbox; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1942 GtkWidget *label; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1943 GtkWidget *entry; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1944 GtkWidget *first, *opt; |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1945 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1946 vbox = gtk_vbox_new(FALSE, 5); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1947 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1948 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("Jabber Options")); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1949 gtk_widget_show(vbox); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1950 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1951 hbox = gtk_hbox_new(TRUE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1952 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1953 gtk_widget_show(hbox); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1954 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1955 first = gtk_radio_button_new_with_label(NULL, "No proxy"); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1956 gtk_box_pack_start(GTK_BOX(hbox), first, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1957 gtk_object_set_user_data(GTK_OBJECT(first), (void *)PROXY_NONE); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1958 gtk_signal_connect(GTK_OBJECT(first), "clicked", GTK_SIGNAL_FUNC(jabber_print_optionrad), user); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1959 gtk_widget_show(first); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1960 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_NONE) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1961 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(first), TRUE); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1962 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1963 opt = |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1964 gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 4"); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1965 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1966 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS4); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1967 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(jabber_print_optionrad), user); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1968 gtk_widget_show(opt); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1969 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS4) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1970 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1971 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1972 hbox = gtk_hbox_new(TRUE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1973 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1974 gtk_widget_show(hbox); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1975 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1976 opt = |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1977 gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "SOCKS 5"); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1978 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1979 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_SOCKS5); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1980 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(jabber_print_optionrad), user); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1981 gtk_widget_show(opt); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1982 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_SOCKS5) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1983 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1984 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1985 opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(first)), "HTTP"); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1986 gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1987 gtk_object_set_user_data(GTK_OBJECT(opt), (void *)PROXY_HTTP); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1988 gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(jabber_print_optionrad), user); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1989 gtk_widget_show(opt); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1990 if (atoi(user->proto_opt[USEROPT_PROXYTYPE]) == PROXY_HTTP) |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1991 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1992 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1993 hbox = gtk_hbox_new(FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1994 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1995 gtk_widget_show(hbox); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1996 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1997 label = gtk_label_new("Proxy Host:"); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1998 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
1999 gtk_widget_show(label); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2000 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2001 entry = gtk_entry_new(); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2002 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2003 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PROXYSERV); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2004 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(jabber_print_option), user); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2005 if (user->proto_opt[USEROPT_PROXYSERV][0]) { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2006 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PROXYSERV]); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2007 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PROXYSERV]); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2008 } |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2009 gtk_widget_show(entry); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2010 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2011 hbox = gtk_hbox_new(FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2012 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2013 gtk_widget_show(hbox); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2014 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2015 label = gtk_label_new("Proxy Port:"); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2016 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2017 gtk_widget_show(label); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2018 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2019 entry = gtk_entry_new(); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2020 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2021 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PROXYPORT); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2022 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(jabber_print_option), user); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2023 if (user->proto_opt[USEROPT_PROXYPORT][0]) { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2024 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PROXYPORT]); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2025 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PROXYPORT]); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2026 } |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2027 gtk_widget_show(entry); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2028 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2029 hbox = gtk_hbox_new(FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2030 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2031 gtk_widget_show(hbox); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2032 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2033 label = gtk_label_new("Proxy User:"); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2034 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2035 gtk_widget_show(label); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2036 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2037 entry = gtk_entry_new(); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2038 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2039 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_USER); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2040 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(jabber_print_option), user); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2041 if (user->proto_opt[USEROPT_USER][0]) { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2042 debug_printf("setting text %s\n", user->proto_opt[USEROPT_USER]); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2043 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_USER]); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2044 } |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2045 gtk_widget_show(entry); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2046 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2047 hbox = gtk_hbox_new(FALSE, 5); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2048 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2049 gtk_widget_show(hbox); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2050 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2051 label = gtk_label_new("Proxy Password:"); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2052 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2053 gtk_widget_show(label); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2054 |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2055 entry = gtk_entry_new(); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2056 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2057 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2058 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_PASS); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2059 gtk_signal_connect(GTK_OBJECT(entry), "changed", GTK_SIGNAL_FUNC(jabber_print_option), user); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2060 if (user->proto_opt[USEROPT_PASS][0]) { |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2061 debug_printf("setting text %s\n", user->proto_opt[USEROPT_PASS]); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2062 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_PASS]); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2063 } |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2064 gtk_widget_show(entry); |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2065 } |
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2066 |
1311 | 2067 static struct prpl *my_protocol = NULL; |
2068 | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
2069 void Jabber_init(struct prpl *ret) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
2070 { |
1311 | 2071 /* the NULL's aren't required but they're nice to have */ |
2072 ret->protocol = PROTO_JABBER; | |
1772
896432d66303
[gaim-migrate @ 1782]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1771
diff
changeset
|
2073 ret->options = OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_CHAT_TOPIC; |
1311 | 2074 ret->name = jabber_name; |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
2075 ret->list_icon = jabber_list_icon; |
1758
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
2076 ret->away_states = jabber_away_states; |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
2077 ret->buddy_menu = jabber_buddy_menu; |
1854
5707d1688165
[gaim-migrate @ 1864]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1853
diff
changeset
|
2078 ret->user_opts = jabber_user_opts; |
1642
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
2079 ret->draw_new_user = jabber_draw_new_user; |
b29f70d97062
[gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1624
diff
changeset
|
2080 ret->do_new_user = jabber_do_new_user; |
1311 | 2081 ret->login = jabber_login; |
2082 ret->close = jabber_close; | |
2083 ret->send_im = jabber_send_im; | |
2084 ret->set_info = NULL; | |
1778
9bc21732ba79
[gaim-migrate @ 1788]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1772
diff
changeset
|
2085 ret->get_info = jabber_get_info; |
1758
eb7b48eef4a3
[gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1735
diff
changeset
|
2086 ret->set_away = jabber_set_away; |
1311 | 2087 ret->get_away_msg = NULL; |
2088 ret->set_dir = NULL; | |
2089 ret->get_dir = NULL; | |
2090 ret->dir_search = NULL; | |
1789
511af0edd6f1
[gaim-migrate @ 1799]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1787
diff
changeset
|
2091 ret->set_idle = jabber_set_idle; |
1311 | 2092 ret->change_passwd = NULL; |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
2093 ret->add_buddy = jabber_add_buddy; |
1311 | 2094 ret->add_buddies = NULL; |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
2095 ret->remove_buddy = jabber_remove_buddy; |
1311 | 2096 ret->add_permit = NULL; |
2097 ret->add_deny = NULL; | |
2098 ret->rem_permit = NULL; | |
2099 ret->rem_deny = NULL; | |
2100 ret->set_permit_deny = NULL; | |
2101 ret->warn = NULL; | |
2102 ret->accept_chat = NULL; | |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
2103 ret->join_chat = jabber_join_chat; |
1724
4104a30264b7
[gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1713
diff
changeset
|
2104 ret->chat_invite = jabber_chat_invite; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
2105 ret->chat_leave = jabber_chat_leave; |
1787
5cd9ed40b34c
[gaim-migrate @ 1797]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1784
diff
changeset
|
2106 ret->chat_whisper = jabber_chat_whisper; |
1466
1a24237f5865
[gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
2107 ret->chat_send = jabber_chat_send; |
1312
f22f57ed13e9
[gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1311
diff
changeset
|
2108 ret->keepalive = NULL; |
1713
14caa7df478c
[gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1707
diff
changeset
|
2109 ret->normalize = jabber_normalize; |
1311 | 2110 |
2111 my_protocol = ret; | |
2112 } | |
2113 | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
2114 char *gaim_plugin_init(GModule *handle) |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
2115 { |
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1363
diff
changeset
|
2116 load_protocol(Jabber_init, sizeof(struct prpl)); |
1311 | 2117 return NULL; |
2118 } | |
2119 | |
1345
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
2120 void gaim_plugin_remove() |
d6e6fcaa1f39
[gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1344
diff
changeset
|
2121 { |
1311 | 2122 struct prpl *p = find_prpl(PROTO_JABBER); |
2123 if (p == my_protocol) | |
2124 unload_protocol(p); | |
2125 } |