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