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