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