annotate plugins/jabber/jabber.c @ 1772:896432d66303

[gaim-migrate @ 1782] remove OPT_USR_KEEPALIVE; add OPT_PROTO_UNIQUE_CHATNAME for Jabber. other things that need to be implemented still. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 30 Apr 2001 01:58:24 +0000
parents 213607e89598
children 9bc21732ba79
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 /*
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 * gaim
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 *
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 *
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * (at your option) any later version.
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 *
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * GNU General Public License for more details.
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 *
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 *
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 */
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
1514
0dd012166152 [gaim-migrate @ 1524]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1499
diff changeset
25 #include "config.h"
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #endif
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include <netdb.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include <unistd.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 #include <errno.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #include <netinet/in.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 #include <arpa/inet.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 #include <string.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 #include <stdlib.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 #include <stdio.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #include <time.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #include <sys/socket.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #include <sys/stat.h>
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #include "multi.h"
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #include "prpl.h"
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #include "gaim.h"
1347
afa63ac2fd84 [gaim-migrate @ 1357]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1345
diff changeset
50 #include "jabber.h"
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51
1344
8b5ed2f0496c [gaim-migrate @ 1354]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1331
diff changeset
52 #include "pixmaps/available.xpm"
1354
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
53 #include "pixmaps/available-away.xpm"
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
54 #include "pixmaps/available-chat.xpm"
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
55 #include "pixmaps/available-xa.xpm"
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
56 #include "pixmaps/available-dnd.xpm"
1344
8b5ed2f0496c [gaim-migrate @ 1354]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1331
diff changeset
57
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 /* The priv member of gjconn's is a gaim_connection for now. */
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 #define GJ_GC(x) ((struct gaim_connection *)(x)->priv)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 #define IQ_NONE -1
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 #define IQ_AUTH 0
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 #define IQ_ROSTER 1
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64
1354
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
65 #define UC_AWAY 0x38
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
66 #define UC_CHAT 0x48
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
67 #define UC_XA 0x98
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
68 #define UC_DND 0x118
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
69
1469
d74112de59ed [gaim-migrate @ 1479]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1466
diff changeset
70 #define DEFAULT_SERVER "jabber.org"
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
71 #define DEFAULT_GROUPCHAT "conference.jabber.org"
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
72
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
73 typedef struct gjconn_struct {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
74 /* Core structure */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
75 pool p; /* Memory allocation pool */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
76 int state; /* Connection state flag */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
77 int fd; /* Connection file descriptor */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
78 jid user; /* User info */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
79 char *pass; /* User passwd */
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
81 /* Stream stuff */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
82 int id; /* id counter for jab_getid() function */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
83 char idbuf[9]; /* temporary storage for jab_getid() */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
84 char *sid; /* stream id from server, for digest auth */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
85 XML_Parser parser; /* Parser instance */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
86 xmlnode current; /* Current node in parsing instance.. */
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
88 /* Event callback ptrs */
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
89 void (*on_state)(struct gjconn_struct *j, int state);
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
90 void (*on_packet)(struct gjconn_struct *j, jpacket p);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
92 void *priv;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 } *gjconn, gjconn_struct;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 typedef void (*gjconn_state_h)(gjconn j, int state);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 typedef void (*gjconn_packet_h)(gjconn j, jpacket p);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 static gjconn gjab_new(char *user, char *pass, void *priv);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 static void gjab_delete(gjconn j);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 static void gjab_state_handler(gjconn j, gjconn_state_h h);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 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
103 static void gjab_start(gjconn j);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 static void gjab_stop(gjconn j);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 static int gjab_getfd(gjconn j);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 static jid gjab_getjid(gjconn j);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 static char *gjab_getsid(gjconn j);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 static char *gjab_getid(gjconn j);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 static void gjab_send(gjconn j, xmlnode x);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 static void gjab_send_raw(gjconn j, const char *str);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 static void gjab_recv(gjconn j);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 static char *gjab_auth(gjconn j);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 struct jabber_data {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
115 gjconn jc;
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
116 gboolean did_import;
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
117 GSList *pending_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
118 GSList *existing_chats;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 };
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
121 static char *jabber_name()
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
122 {
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 return "Jabber";
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
126 char *name()
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
127 {
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 return "Jabber";
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
131 char *description()
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
132 {
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 return "Allows gaim to use the Jabber protocol";
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 #define STATE_EVT(arg) if(j->on_state) { (j->on_state)(j, (arg) ); }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
138 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
139 {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
140 char *valid;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
141
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
142 if (!strchr(given, '@'))
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
143 valid = g_strdup_printf("%s@%s/%s", given, server, resource);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
144 else if (!strchr(strchr(given, '@'), '/'))
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
145 valid = g_strdup_printf("%s/%s", given, resource);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
146 else
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
147 valid = g_strdup(given);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
148
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
149 return valid;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
150 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
151
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 static gjconn gjab_new(char *user, char *pass, void *priv)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
154 pool p;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
155 gjconn j;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
157 if (!user)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
158 return (NULL);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
160 p = pool_new();
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
161 if (!p)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
162 return (NULL);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
163 j = pmalloc_x(p, sizeof(gjconn_struct), 0);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
164 if (!j)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
165 return (NULL);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
166 j->p = p;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
168 j->user = jid_new(p, user);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
169 j->pass = pstrdup(p, pass);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
171 j->state = JCONN_STATE_OFF;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
172 j->id = 1;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
173 j->fd = -1;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
175 j->priv = priv;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
177 return j;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 static void gjab_delete(gjconn j)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
182 if (!j)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
183 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
185 gjab_stop(j);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
186 pool_free(j->p);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 static void gjab_state_handler(gjconn j, gjconn_state_h h)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
191 if (!j)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
192 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
194 j->on_state = h;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 static void gjab_packet_handler(gjconn j, gjconn_packet_h h)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
199 if (!j)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
200 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
202 j->on_packet = h;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 static void gjab_stop(gjconn j)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
207 if (!j || j->state == JCONN_STATE_OFF)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
208 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
210 j->state = JCONN_STATE_OFF;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
211 gjab_send_raw(j, "</stream:stream>");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
212 close(j->fd);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
213 j->fd = -1;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
214 XML_ParserFree(j->parser);
1668
91cddbcfdd17 [gaim-migrate @ 1678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1666
diff changeset
215 j->parser = NULL;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 static int gjab_getfd(gjconn j)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
220 if (j)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
221 return j->fd;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
222 else
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
223 return -1;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 static jid gjab_getjid(gjconn j)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
228 if (j)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
229 return (j->user);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
230 else
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
231 return NULL;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 static char *gjab_getsid(gjconn j)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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->sid);
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 NULL;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 static char *gjab_getid(gjconn j)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
244 snprintf(j->idbuf, 8, "%d", j->id++);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
245 return &j->idbuf[0];
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 static void gjab_send(gjconn j, xmlnode x)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
250 if (j && j->state != JCONN_STATE_OFF) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
251 char *buf = xmlnode2str(x);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
252 if (buf)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
253 write(j->fd, buf, strlen(buf));
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
254 debug_printf("gjab_send: %s\n", buf);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
255 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 static void gjab_send_raw(gjconn j, const char *str)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
260 if (j && j->state != JCONN_STATE_OFF) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
261 write(j->fd, str, strlen(str));
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
262 debug_printf("gjab_send_raw: %s\n", str);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
263 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 static void gjab_reqroster(gjconn j)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
268 xmlnode x;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
269 char *id;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
271 x = jutil_iqnew(JPACKET__GET, NS_ROSTER);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
272 id = gjab_getid(j);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
273 xmlnode_put_attrib(x, "id", id);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
275 gjab_send(j, x);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
276 xmlnode_free(x);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 static char *gjab_auth(gjconn j)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
281 xmlnode x, y, z;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
282 char *hash, *user, *id;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
284 if (!j)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
285 return NULL;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
287 x = jutil_iqnew(JPACKET__SET, NS_AUTH);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
288 id = gjab_getid(j);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
289 xmlnode_put_attrib(x, "id", id);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
290 y = xmlnode_get_tag(x, "query");
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
292 user = j->user->user;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
294 if (user) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
295 z = xmlnode_insert_tag(y, "username");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
296 xmlnode_insert_cdata(z, user, -1);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
297 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
299 z = xmlnode_insert_tag(y, "resource");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
300 xmlnode_insert_cdata(z, j->user->resource, -1);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
302 if (j->sid) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
303 z = xmlnode_insert_tag(y, "digest");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
304 hash = pmalloc(x->p, strlen(j->sid) + strlen(j->pass) + 1);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
305 strcpy(hash, j->sid);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
306 strcat(hash, j->pass);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
307 hash = shahash(hash);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
308 xmlnode_insert_cdata(z, hash, 40);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
309 } else {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
310 z = xmlnode_insert_tag(y, "password");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
311 xmlnode_insert_cdata(z, j->pass, -1);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
312 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
314 gjab_send(j, x);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
315 xmlnode_free(x);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
317 return id;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 static void gjab_recv(gjconn j)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
322 static char buf[4096];
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
323 int len;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
325 if (!j || j->state == JCONN_STATE_OFF)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
326 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
328 if ((len = read(j->fd, buf, sizeof(buf) - 1))) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
329 buf[len] = '\0';
1668
91cddbcfdd17 [gaim-migrate @ 1678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1666
diff changeset
330 debug_printf("input (len %d): %s\n", len, buf);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
331 XML_Parse(j->parser, buf, len, 0);
1551
497a074fa1c8 [gaim-migrate @ 1561]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1522
diff changeset
332 } else if (len <= 0) {
1666
8b0c165a33f4 [gaim-migrate @ 1676]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1665
diff changeset
333 STATE_EVT(JCONN_STATE_OFF)
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
334 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 static void startElement(void *userdata, const char *name, const char **attribs)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
339 xmlnode x;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
340 gjconn j = (gjconn) userdata;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
342 if (j->current) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
343 /* Append the node to the current one */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
344 x = xmlnode_insert_tag(j->current, name);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
345 xmlnode_put_expat_attribs(x, attribs);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
347 j->current = x;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
348 } else {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
349 x = xmlnode_new_tag(name);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
350 xmlnode_put_expat_attribs(x, attribs);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
351 if (strcmp(name, "stream:stream") == 0) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
352 /* special case: name == stream:stream */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
353 /* id attrib of stream is stored for digest auth */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
354 j->sid = xmlnode_get_attrib(x, "id");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
355 /* STATE_EVT(JCONN_STATE_AUTH) */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
356 } else {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
357 j->current = x;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
358 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
359 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 static void endElement(void *userdata, const char *name)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
364 gjconn j = (gjconn) userdata;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
365 xmlnode x;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
366 jpacket p;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
368 if (j->current == NULL) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
369 /* we got </stream:stream> */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
370 STATE_EVT(JCONN_STATE_OFF)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
371 return;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
372 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
374 x = xmlnode_get_parent(j->current);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
376 if (!x) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
377 /* it is time to fire the event */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
378 p = jpacket_new(j->current);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
380 if (j->on_packet)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
381 (j->on_packet) (j, p);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
382 else
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
383 xmlnode_free(j->current);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
384 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
386 j->current = x;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 static void charData(void *userdata, const char *s, int slen)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
391 gjconn j = (gjconn) userdata;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
393 if (j->current)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
394 xmlnode_insert_cdata(j->current, s, slen);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396
1331
f48cb8ddca59 [gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1316
diff changeset
397 static void gjab_start(gjconn j)
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
399 xmlnode x;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
400 char *t, *t2;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
402 if (!j || j->state != JCONN_STATE_OFF)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
403 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
405 j->parser = XML_ParserCreate(NULL);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
406 XML_SetUserData(j->parser, (void *)j);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
407 XML_SetElementHandler(j->parser, startElement, endElement);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
408 XML_SetCharacterDataHandler(j->parser, charData);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
410 j->fd = make_netsocket(5222, j->user->server, NETSOCKET_CLIENT);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
411 if (j->fd < 0) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
412 STATE_EVT(JCONN_STATE_OFF)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
413 return;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
414 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
415 j->state = JCONN_STATE_CONNECTED;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
416 STATE_EVT(JCONN_STATE_CONNECTED)
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
418 /* start stream */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
419 x = jutil_header(NS_CLIENT, j->user->server);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
420 t = xmlnode2str(x);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
421 /* 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
422 /* what do you think about it? -madcat */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
423 t2 = strstr(t, "/>");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
424 *t2++ = '>';
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
425 *t2 = '\0';
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
426 gjab_send_raw(j, "<?xml version='1.0'?>");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
427 gjab_send_raw(j, t);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
428 xmlnode_free(x);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
430 j->state = JCONN_STATE_ON;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
431 STATE_EVT(JCONN_STATE_ON)
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
434 static void jabber_callback(gpointer data, gint source, GdkInputCondition condition)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
435 {
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 struct gaim_connection *gc = (struct gaim_connection *)data;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 struct jabber_data *jd = (struct jabber_data *)gc->proto_data;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
439 gjab_recv(jd->jc);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
442 static struct conversation *find_chat(struct gaim_connection *gc, char *name)
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
443 {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
444 GSList *bcs = gc->buddy_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
445 struct conversation *b = NULL;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
446 char *chat = g_strdup(normalize(name));
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
447
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
448 while (bcs) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
449 b = bcs->data;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
450 if (!strcasecmp(normalize(b->name), chat))
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
451 break;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
452 b = NULL;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
453 bcs = bcs->next;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
454 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
455
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
456 g_free(chat);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
457 return b;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
458 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
459
1682
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
460 static gboolean find_chat_buddy(struct conversation *b, char *name)
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
461 {
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
462 GList *m = b->in_room;
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
463
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
464 while (m) {
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
465 if (!strcasecmp(m->data, name))
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
466 return TRUE;
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
467 m = m->next;
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
468 }
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
469
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
470 return FALSE;
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
471 }
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
472
1771
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
473 static unsigned char *utf8_to_str(unsigned char *in)
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
474 {
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
475 int n = 0,i = 0;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
476 int inlen;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
477 unsigned char *result;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
478
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
479 if (!in)
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
480 return NULL;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
481
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
482 inlen = strlen(in);
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
483
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
484 result = (unsigned char*)malloc(inlen+1);
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
485
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
486 while(n <= inlen-1) {
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
487 long c = (long)in[n];
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
488 if(c<0x80)
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
489 result[i++] = (char)c;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
490 else {
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
491 if((c&0xC0) == 0xC0)
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
492 result[i++] = (char)(((c&0x03)<<6)|(((unsigned char)in[++n])&0x3F));
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
493 else if((c&0xE0) == 0xE0) {
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
494 if (n + 2 <= inlen) {
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
495 result[i] = (char)(((c&0xF)<<4)|(((unsigned char)in[++n])&0x3F));
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
496 result[i] = (char)(((unsigned char)result[i]) |(((unsigned char)in[++n])&0x3F));
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
497 i++;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
498 } else n += 2;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
499 }
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
500 else if((c&0xF0) == 0xF0)
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
501 n += 3;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
502 else if((c&0xF8) == 0xF8)
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
503 n += 4;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
504 else if((c&0xFC) == 0xFC)
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
505 n += 5;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
506 }
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
507 n++;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
508 }
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
509 result[i] = '\0';
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
510
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
511 return result;
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
512 }
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
513
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
514 static void jabber_handlemessage(gjconn j, jpacket p)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 {
1724
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
516 xmlnode y, xmlns;
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
517 gboolean same = TRUE;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
519 char *from = NULL, *msg = NULL, *type = NULL;
1682
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
520 char m[BUF_LONG * 2];
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
521
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
522 type = xmlnode_get_attrib(p->x, "type");
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
523
1485
5e00250ada1e [gaim-migrate @ 1495]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1469
diff changeset
524 if (!type || !strcmp(type, "normal") || !strcmp(type, "chat")) {
1724
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
525
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
526 /* XXX namespaces could be handled better. (mid) */
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
527 if ((xmlns = xmlnode_get_tag(p->x, "x")))
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
528 type = xmlnode_get_attrib(xmlns, "xmlns");
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
529
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
530 from = jid_full(p->from);
1771
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
531 if ((y = xmlnode_get_tag(p->x, "html"))) {
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
532 msg = xmlnode_get_data(y);
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
533 } else if ((y = xmlnode_get_tag(p->x, "body"))) {
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
534 msg = xmlnode_get_data(y);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
535 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
536
1771
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
537 msg = utf8_to_str(msg);
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
538
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
539 if (!from || !msg) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
540 return;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
541 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542
1724
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
543 if (type && !strcmp(type, "jabber:x:conference")) {
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
544 char *room;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
545
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
546 room = xmlnode_get_attrib(xmlns, "jid");
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
547
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
548 serv_got_chat_invite(GJ_GC(j), room, 0, from, msg);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
549
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
550 } else {
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
551 if (!find_conversation(from) && jid_cmp(p->from, jid_new(j->p, GJ_GC(j)->username))) {
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
552 from = g_strdup_printf("%s@%s", p->from->user, p->from->server);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
553 same = FALSE;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
554 }
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
555
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
556 g_snprintf(m, sizeof(m), "%s", msg);
1764
1e0613d9526b [gaim-migrate @ 1774]
Rob Flynn <gaim@robflynn.com>
parents: 1758
diff changeset
557 serv_got_im(GJ_GC(j), from, m, 0, time((time_t)NULL));
1724
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
558
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
559 if (!same)
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
560 g_free(from);
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
561 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
562
1771
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
563 free(msg);
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
564
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
565 } else if (!strcmp(type, "error")) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
566 if ((y = xmlnode_get_tag(p->x, "error"))) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
567 type = xmlnode_get_attrib(y, "code");
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
568 msg = xmlnode_get_data(y);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
569 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
571 if (msg) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
572 from = g_strdup_printf("Error %s", type ? type : "");
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
573 do_error_dialog(msg, from);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
574 g_free(from);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
575 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
576 } else if (!strcmp(type, "groupchat")) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
577 struct conversation *b;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
578 static int i = 0;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
579 from = jid_full(p->from);
1771
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
580
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
581 if ((y = xmlnode_get_tag(p->x, "html"))) {
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
582 msg = xmlnode_get_data(y);
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
583 } else if ((y = xmlnode_get_tag(p->x, "body"))) {
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
584 msg = xmlnode_get_data(y);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
585 }
1771
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
586
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
587 msg = utf8_to_str(msg);
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
588
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
589 b = find_chat(GJ_GC(j), p->from->user);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
590 if (!b) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
591 jid chat = NULL;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
592 struct jabber_data *jd = GJ_GC(j)->proto_data;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
593 GSList *pc = jd->pending_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
594 while (pc) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
595 chat = jid_new(j->p, pc->data); /* whoa */
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
596 if (!strcasecmp(p->from->user, chat->user))
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
597 break;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
598 pc = pc->next;
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 if (pc) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
601 serv_got_joined_chat(GJ_GC(j), i++, p->from->user);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
602 b = find_chat(GJ_GC(j), p->from->user);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
603 jd->existing_chats = g_slist_append(jd->existing_chats, pc->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
604 jd->pending_chats = g_slist_remove(jd->pending_chats, pc->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
605 } else {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
606 return;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
607 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
608 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
609 if (p->from->resource) {
1682
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
610 if (!y) {
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
611 if (!find_chat_buddy(b, p->from->resource))
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
612 add_chat_buddy(b, p->from->resource);
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
613 else if ((y = xmlnode_get_tag(p->x, "status"))) {
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
614 char buf[8192];
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
615 msg = xmlnode_get_data(y);
1735
00f74db70f2d [gaim-migrate @ 1745]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1724
diff changeset
616 g_snprintf(buf, sizeof(buf), "%s now has status: %s",
1682
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
617 p->from->resource, msg);
1764
1e0613d9526b [gaim-migrate @ 1774]
Rob Flynn <gaim@robflynn.com>
parents: 1758
diff changeset
618 write_to_conv(b, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL));
1682
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
619 }
1688
85d8c64e969d [gaim-migrate @ 1698]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1684
diff changeset
620 } else if (msg) {
85d8c64e969d [gaim-migrate @ 1698]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1684
diff changeset
621 char buf[8192];
85d8c64e969d [gaim-migrate @ 1698]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1684
diff changeset
622 g_snprintf(buf, sizeof(buf), "%s", msg);
1764
1e0613d9526b [gaim-migrate @ 1774]
Rob Flynn <gaim@robflynn.com>
parents: 1758
diff changeset
623 serv_got_chat_in(GJ_GC(j), b->id, p->from->resource, 0, buf, time((time_t)NULL));
1688
85d8c64e969d [gaim-migrate @ 1698]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1684
diff changeset
624 }
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
625 }
1771
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
626
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
627 free(msg);
213607e89598 [gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1765
diff changeset
628
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
629 } else {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
630 debug_printf("unhandled message %s\n", type);
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
631 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634 static void jabber_handlepresence(gjconn j, jpacket p)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
636 char *to, *from, *type;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
637 struct buddy *b;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
638 jid who;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
639 char *buddy;
1354
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
640 xmlnode y;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
641 char *show;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
642 int state;
1359
f0c2d6b88b14 [gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1354
diff changeset
643 GSList *resources;
f0c2d6b88b14 [gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1354
diff changeset
644 char *res;
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
645 struct conversation *cnv = NULL;
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
646
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
647 to = xmlnode_get_attrib(p->x, "to");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
648 from = xmlnode_get_attrib(p->x, "from");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
649 type = xmlnode_get_attrib(p->x, "type");
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650
1354
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
651 if ((y = xmlnode_get_tag(p->x, "show"))) {
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
652 show = xmlnode_get_data(y);
1758
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
653 if (!show) {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
654 state = UC_NORMAL;
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
655 } else if (!strcmp(show, "away")) {
1354
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
656 state = UC_AWAY;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
657 } else if (!strcmp(show, "chat")) {
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
658 state = UC_CHAT;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
659 } else if (!strcmp(show, "xa")) {
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
660 state = UC_XA;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
661 } else if (!strcmp(show, "dnd")) {
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
662 state = UC_DND;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
663 }
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
664 } else {
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
665 state = UC_NORMAL;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
666 }
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
667
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
668 who = jid_new(j->p, from);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
669 if (who->user == NULL) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
670 /* FIXME: transport */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
671 return;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
672 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
673
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
674 buddy = g_strdup_printf("%s@%s", who->user, who->server);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
675
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
676 /* 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
677 * 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
678 if ((cnv = find_chat(GJ_GC(j), who->user)) == NULL) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
679 static int i = 0x70;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
680 jid chat = NULL;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
681 struct jabber_data *jd = GJ_GC(j)->proto_data;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
682 GSList *pc = jd->pending_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
683
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
684 while (pc) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
685 chat = jid_new(j->p, pc->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
686 if (!jid_cmpx(who, chat, JID_USER | JID_SERVER))
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
687 break;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
688 pc = pc->next;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
689 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
690 if (pc) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
691 serv_got_joined_chat(GJ_GC(j), i++, who->user);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
692 cnv = find_chat(GJ_GC(j), who->user);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
693 jd->existing_chats = g_slist_append(jd->existing_chats, pc->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
694 jd->pending_chats = g_slist_remove(jd->pending_chats, pc->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
695 } else if (!(b = find_buddy(GJ_GC(j), buddy))) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
696 b = add_buddy(GJ_GC(j), "Buddies", buddy, buddy);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
697 do_export(NULL, NULL);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
698 }
1359
f0c2d6b88b14 [gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1354
diff changeset
699 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
701 if (!cnv) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
702 resources = b->proto_data;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
703 res = who->resource;
1611
9ff8cac19352 [gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1551
diff changeset
704 if (res)
9ff8cac19352 [gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1551
diff changeset
705 while (resources) {
9ff8cac19352 [gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1551
diff changeset
706 if (!strcmp(res, resources->data))
9ff8cac19352 [gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1551
diff changeset
707 break;
9ff8cac19352 [gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1551
diff changeset
708 resources = resources->next;
9ff8cac19352 [gaim-migrate @ 1621]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1551
diff changeset
709 }
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
710
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
711 if (type && (strcasecmp(type, "unavailable") == 0)) {
1624
12bd198b6721 [gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1611
diff changeset
712 if (resources) {
12bd198b6721 [gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1611
diff changeset
713 g_free(resources->data);
12bd198b6721 [gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1611
diff changeset
714 b->proto_data = g_slist_remove(b->proto_data, resources->data);
12bd198b6721 [gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1611
diff changeset
715 }
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
716 if (!b->proto_data) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
717 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
718 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
719 } else {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
720 if (!resources) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
721 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
722 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
723 serv_got_update(GJ_GC(j), buddy, 1, 0, 0, 0, state, 0);
1359
f0c2d6b88b14 [gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1354
diff changeset
724 }
f0c2d6b88b14 [gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1354
diff changeset
725 } else {
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
726 if (who->resource) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
727 if (type && !strcmp(type, "unavailable")) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
728 struct jabber_data *jd = GJ_GC(j)->proto_data;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
729 GSList *bcs = jd->existing_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
730 jid chat;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
731 while (bcs) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
732 chat = jid_new(j->p, bcs->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
733 if (!strcasecmp(cnv->name, chat->user))
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
734 break;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
735 bcs = bcs->next;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
736 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
737 if (!bcs) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
738 return;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
739 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
740
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
741 if (strcasecmp(who->resource, chat->resource)) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
742 remove_chat_buddy(cnv, who->resource);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
743 return;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
744 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
745
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
746 g_free(bcs->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
747 jd->existing_chats = g_slist_remove(jd->existing_chats, bcs->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
748 serv_got_chat_left(GJ_GC(j), cnv->id);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
749 } else {
1682
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
750 if (!find_chat_buddy(cnv, who->resource))
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
751 add_chat_buddy(cnv, who->resource);
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
752 else if ((y = xmlnode_get_tag(p->x, "status"))) {
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
753 char buf[8192];
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
754 char *msg = xmlnode_get_data(y);
1735
00f74db70f2d [gaim-migrate @ 1745]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1724
diff changeset
755 g_snprintf(buf, sizeof(buf), "%s now has status: %s",
1682
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
756 p->from->resource, msg);
1764
1e0613d9526b [gaim-migrate @ 1774]
Rob Flynn <gaim@robflynn.com>
parents: 1758
diff changeset
757 write_to_conv(cnv, buf, WFLAG_SYSTEM, NULL, time((time_t)NULL));
1682
4328efeb531e [gaim-migrate @ 1692]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1668
diff changeset
758 }
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
759 }
1359
f0c2d6b88b14 [gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1354
diff changeset
760 }
f0c2d6b88b14 [gaim-migrate @ 1369]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1354
diff changeset
761 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
763 g_free(buddy);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
764
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
765 return;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
766 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
767
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
768 static void jabber_handles10n(gjconn j, jpacket p)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
769 {
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
770 xmlnode g;
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
771 char *Jid = xmlnode_get_attrib(p->x, "from");
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
772 char *ask = xmlnode_get_attrib(p->x, "type");
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
773
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
774 g = xmlnode_new_tag("presence");
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
775 xmlnode_put_attrib(g, "to", Jid);
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
776 if (!strcmp(ask, "subscribe"))
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
777 xmlnode_put_attrib(g, "type", "subscribed");
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
778 else if (!strcmp(ask, "unsubscribe"))
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
779 xmlnode_put_attrib(g, "type", "unsubscribed");
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
780 else
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
781 return;
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
782
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
783 gjab_send(j, g);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786 static void jabber_handleroster(gjconn j, xmlnode querynode)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
788 xmlnode x;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
790 x = xmlnode_get_firstchild(querynode);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
791 while (x) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
792 xmlnode g;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
793 char *Jid, *name, *sub, *ask;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
794 jid who;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
795
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
796 Jid = xmlnode_get_attrib(x, "jid");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
797 name = xmlnode_get_attrib(x, "name");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
798 sub = xmlnode_get_attrib(x, "subscription");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
799 ask = xmlnode_get_attrib(x, "ask");
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
800 who = jid_new(j->p, Jid);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
801
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
802 if ((g = xmlnode_get_firstchild(x))) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
803 while (g) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
804 if (strncasecmp(xmlnode_get_name(g), "group", 5) == 0) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
805 struct buddy *b;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
806 char *groupname, *buddyname;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
807
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
808 if (who->user == NULL) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
809 /* FIXME: transport */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
810 g = xmlnode_get_nextsibling(g);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
811 continue;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
812 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
813 buddyname = g_strdup_printf("%s@%s", who->user, who->server);
1522
31c0850f9340 [gaim-migrate @ 1532]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1514
diff changeset
814 groupname = xmlnode_get_data(xmlnode_get_firstchild(g));
31c0850f9340 [gaim-migrate @ 1532]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1514
diff changeset
815 if (groupname == NULL)
31c0850f9340 [gaim-migrate @ 1532]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1514
diff changeset
816 groupname = "Buddies";
1758
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
817 if (strcasecmp(sub, "from") && strcasecmp(sub, "none") &&
1683
394a3a344273 [gaim-migrate @ 1693]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1682
diff changeset
818 !(b = find_buddy(GJ_GC(j), buddyname))) {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
819 debug_printf("adding buddy: %s\n", buddyname);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
820 b =
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
821 add_buddy(GJ_GC(j), groupname, buddyname,
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
822 name ? name : buddyname);
1344
8b5ed2f0496c [gaim-migrate @ 1354]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1331
diff changeset
823 do_export(0, 0);
1758
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
824 } else if (b) {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
825 debug_printf("updating buddy: %s/%s\n", buddyname, name);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
826 g_snprintf(b->name, sizeof(b->name), "%s", buddyname);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
827 g_snprintf(b->show, sizeof(b->show), "%s",
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
828 name ? name : buddyname);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
829 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
830 g_free(buddyname);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
831 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
832 g = xmlnode_get_nextsibling(g);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
833 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
834 } else {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
835 struct buddy *b;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
836 char *buddyname;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
837
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
838 if (who->user == NULL) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
839 /* FIXME: transport */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
840 x = xmlnode_get_nextsibling(x);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
841 continue;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
842 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
843 buddyname = g_strdup_printf("%s@%s", who->user, who->server);
1758
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
844 if (strcasecmp(sub, "from") && strcasecmp(sub, "none") &&
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
845 !(b = find_buddy(GJ_GC(j), buddyname))) {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
846 b = add_buddy(GJ_GC(j), "Buddies", buddyname, name ? name : Jid);
1344
8b5ed2f0496c [gaim-migrate @ 1354]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1331
diff changeset
847 do_export(0, 0);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
848 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
849 g_free(buddyname);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
850 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
852 x = xmlnode_get_nextsibling(x);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
853 }
1331
f48cb8ddca59 [gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1316
diff changeset
854
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
855 x = jutil_presnew(0, NULL, "Online");
1331
f48cb8ddca59 [gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1316
diff changeset
856 gjab_send(j, x);
f48cb8ddca59 [gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1316
diff changeset
857 xmlnode_free(x);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
858 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
859
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
860 static void jabber_handlepacket(gjconn j, jpacket p)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
862 switch (p->type) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
863 case JPACKET_MESSAGE:
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
864 jabber_handlemessage(j, p);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
865 break;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
866 case JPACKET_PRESENCE:
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
867 jabber_handlepresence(j, p);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
868 break;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
869 case JPACKET_IQ:
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
870 debug_printf("jpacket_subtype: %d\n", jpacket_subtype(p));
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
872 if (jpacket_subtype(p) == JPACKET__SET) {
1684
89c19002e73d [gaim-migrate @ 1694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1683
diff changeset
873 } else if (jpacket_subtype(p) == JPACKET__GET) {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
874 } else if (jpacket_subtype(p) == JPACKET__RESULT) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
875 xmlnode querynode;
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
876 char *xmlns, *from;
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
877
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
878 from = xmlnode_get_attrib(p->x, "from");
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
879 querynode = xmlnode_get_tag(p->x, "query");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
880 xmlns = xmlnode_get_attrib(querynode, "xmlns");
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
881
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
882 if ((!xmlns && !from) || NSCHECK(querynode, NS_AUTH)) {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
883 debug_printf("auth success\n");
1331
f48cb8ddca59 [gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1316
diff changeset
884
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
885 account_online(GJ_GC(j));
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
886 serv_finish_login(GJ_GC(j));
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
887
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
888 if (bud_list_cache_exists(GJ_GC(j)))
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
889 do_import(NULL, GJ_GC(j));
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
890
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
891 ((struct jabber_data *)GJ_GC(j)->proto_data)->did_import = TRUE;
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
892
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
893 gjab_reqroster(j);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
895 } else if (NSCHECK(querynode, NS_ROSTER)) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
896 jabber_handleroster(j, querynode);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
897 } else {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
898 /* debug_printf("jabber:iq:query: %s\n", xmlns); */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
899 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
900 } else {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
901 xmlnode x;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
903 debug_printf("auth failed\n");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
904 x = xmlnode_get_tag(p->x, "error");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
905 if (x) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
906 debug_printf("error %d: %s\n\n",
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
907 atoi(xmlnode_get_attrib(x, "code")),
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
908 xmlnode_get_data(xmlnode_get_firstchild(x)));
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909
1707
5417bf0c8e28 [gaim-migrate @ 1717]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1704
diff changeset
910 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911
1665
fc77d4f1599e [gaim-migrate @ 1675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1644
diff changeset
912 xmlnode_free(p->x);
1704
07097db15338 [gaim-migrate @ 1714]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1699
diff changeset
913 gjab_send_raw(j, "</stream:stream>");
1665
fc77d4f1599e [gaim-migrate @ 1675]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1644
diff changeset
914 return;
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
915 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
916 break;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
917 case JPACKET_S10N:
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
918 jabber_handles10n(j, p);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
919 break;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
920 default:
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
921 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
922 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
923
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
924 xmlnode_free(p->x);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
925
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
926 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
928
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
929 static void jabber_handlestate(gjconn j, int state)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
930 {
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
931 switch (state) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
932 case JCONN_STATE_OFF:
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
933 hide_login_progress(GJ_GC(j), "Unable to connect");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
934 signoff(GJ_GC(j));
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
935 break;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
936 case JCONN_STATE_CONNECTED:
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
937 set_login_progress(GJ_GC(j), 3, "Connected");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
938 break;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
939 case JCONN_STATE_ON:
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
940 set_login_progress(GJ_GC(j), 5, "Logging in...");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
941 gjab_auth(j);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
942 break;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
943 default:
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
944 debug_printf("state change: %d\n", state);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
945 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
946 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
947 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
948
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
949 static void jabber_login(struct aim_user *user)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
950 {
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951 struct gaim_connection *gc = new_gaim_conn(user);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
952 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
953 char *loginname = create_valid_jid(user->username, DEFAULT_SERVER, "GAIM");
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
954
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
955 set_login_progress(gc, 1, "Connecting");
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
956
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
957 if (!(jd->jc = gjab_new(loginname, user->password, gc))) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
958 g_free(loginname);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
959 debug_printf("jabber: unable to connect (jab_new failed)\n");
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
960 hide_login_progress(gc, "Unable to connect");
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961 signoff(gc);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
962 return;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
963 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
964
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
965 g_free(loginname);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
966 gjab_state_handler(jd->jc, jabber_handlestate);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
967 gjab_packet_handler(jd->jc, jabber_handlepacket);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
968 gjab_start(jd->jc);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969
1624
12bd198b6721 [gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1611
diff changeset
970 if (gc->proto_data)
12bd198b6721 [gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1611
diff changeset
971 gc->inpa = gdk_input_add(jd->jc->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
12bd198b6721 [gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1611
diff changeset
972 jabber_callback, gc);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
974 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
977 static void jabber_close(struct gaim_connection *gc)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
978 {
1312
f22f57ed13e9 [gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1311
diff changeset
979 struct jabber_data *jd = gc->proto_data;
f22f57ed13e9 [gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1311
diff changeset
980 gdk_input_remove(gc->inpa);
1666
8b0c165a33f4 [gaim-migrate @ 1676]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1665
diff changeset
981 gjab_delete(jd->jc);
8b0c165a33f4 [gaim-migrate @ 1676]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1665
diff changeset
982 jd->jc = NULL;
1312
f22f57ed13e9 [gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1311
diff changeset
983 g_free(jd);
1624
12bd198b6721 [gaim-migrate @ 1634]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1611
diff changeset
984 gc->proto_data = NULL;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
986
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
987 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
988 {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
989 xmlnode x, y;
1316
d5069ad0b6b1 [gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1315
diff changeset
990 char *realwho;
d5069ad0b6b1 [gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1315
diff changeset
991 gjconn j = ((struct jabber_data *)gc->proto_data)->jc;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
993 if (!who || !message)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
994 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
996 x = xmlnode_new_tag("message");
1316
d5069ad0b6b1 [gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1315
diff changeset
997 if (!strchr(who, '@'))
d5069ad0b6b1 [gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1315
diff changeset
998 realwho = g_strdup_printf("%s@%s", who, j->user->server);
d5069ad0b6b1 [gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1315
diff changeset
999 else
d5069ad0b6b1 [gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1315
diff changeset
1000 realwho = g_strdup(who);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1001 xmlnode_put_attrib(x, "to", realwho);
1316
d5069ad0b6b1 [gaim-migrate @ 1326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1315
diff changeset
1002 g_free(realwho);
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1004 xmlnode_put_attrib(x, "type", "chat");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1005
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1006 if (message && strlen(message)) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1007 y = xmlnode_insert_tag(x, "body");
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1008 xmlnode_insert_cdata(y, message, -1);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1009 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1010
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1011 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x);
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1012 xmlnode_free(x);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1013 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1014
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1015 static void jabber_add_buddy(struct gaim_connection *gc, char *name)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1016 {
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1017 xmlnode x, y;
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1018 char *realwho;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1019 gjconn j = ((struct jabber_data *)gc->proto_data)->jc;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1020
1362
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
1021 if (!((struct jabber_data *)gc->proto_data)->did_import)
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
1022 return;
3cea00ca7a34 [gaim-migrate @ 1372]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1359
diff changeset
1023
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1024 if (!name)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1025 return;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1026
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1027 if (!strcmp(gc->username, name))
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1028 return;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1029
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1030 if (!strchr(name, '@'))
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1031 realwho = g_strdup_printf("%s@%s", name, j->user->server);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1032 else {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1033 jid who = jid_new(j->p, name);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1034 if (who->user == NULL) {
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1035 /* FIXME: transport */
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1036 return;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1037 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1038 realwho = g_strdup_printf("%s@%s", who->user, who->server);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1039 }
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1040
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1041 x = jutil_iqnew(JPACKET__SET, NS_ROSTER);
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1042 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item");
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1043 xmlnode_put_attrib(y, "jid", realwho);
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1044 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x);
1363
b454b1d084ce [gaim-migrate @ 1373]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1362
diff changeset
1045 xmlnode_free(x);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1046
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1047 x = xmlnode_new_tag("presence");
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1048 xmlnode_put_attrib(x, "to", realwho);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1049 xmlnode_put_attrib(x, "type", "subscribe");
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1050 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1051
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1052 g_free(realwho);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1053 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1055 static void jabber_remove_buddy(struct gaim_connection *gc, char *name)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1056 {
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1057 xmlnode x, y;
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1058 char *realwho;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1059 gjconn j = ((struct jabber_data *)gc->proto_data)->jc;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1060
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1061 if (!name)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1062 return;
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1063
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1064 if (!strchr(name, '@'))
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1065 realwho = g_strdup_printf("%s@%s", name, j->user->server);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1066 else
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1067 realwho = g_strdup(name);
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1068
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1069 x = jutil_iqnew(JPACKET__SET, NS_ROSTER);
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1070 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item");
1353
f6a8bca11766 [gaim-migrate @ 1363]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1349
diff changeset
1071 xmlnode_put_attrib(y, "jid", realwho);
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1072 xmlnode_put_attrib(y, "subscription", "remove");
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1073 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1074
1349
9e647319dd63 [gaim-migrate @ 1359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1347
diff changeset
1075 g_free(realwho);
1363
b454b1d084ce [gaim-migrate @ 1373]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1362
diff changeset
1076 xmlnode_free(x);
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1077 }
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1078
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1079 static char **jabber_list_icon(int uc)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1080 {
1354
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1081 switch (uc) {
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1082 case UC_AWAY:
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1083 return available_away_xpm;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1084 case UC_CHAT:
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1085 return available_chat_xpm;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1086 case UC_XA:
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1087 return available_xa_xpm;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1088 case UC_DND:
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1089 return available_dnd_xpm;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1090 default:
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1091 return available_xpm;
6b0a7cea1dd1 [gaim-migrate @ 1364]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1353
diff changeset
1092 }
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1094
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1095 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
1096 {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1097 xmlnode x, y;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1098 char *realwho;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1099 gjconn j = ((struct jabber_data *)gc->proto_data)->jc;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1100 GSList *pc = ((struct jabber_data *)gc->proto_data)->pending_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1101
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1102 if (!name)
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1103 return;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1104
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1105 realwho = create_valid_jid(name, DEFAULT_GROUPCHAT, j->user->user);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1106
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1107 x = jutil_presnew(0, realwho, NULL);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1108 gjab_send(j, x);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1109 xmlnode_free(x);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1110
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1111 ((struct jabber_data *)gc->proto_data)->pending_chats = g_slist_append(pc, realwho);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1112 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1113
1724
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1114 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
1115 {
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1116 xmlnode x, y;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1117 GSList *bcs = gc->buddy_chats;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1118 struct conversation *b;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1119 struct jabber_data *jd = gc->proto_data;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1120 gjconn j = jd->jc;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1121 jid chat;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1122 char *realwho, *subject;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1123
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1124 if (!name)
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1125 return;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1126
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1127 while (bcs) {
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1128 b = bcs->data;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1129 if (id == b->id)
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1130 break;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1131 bcs = bcs->next;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1132 }
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1133 if (!bcs)
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1134 return;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1135
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1136 bcs = jd->existing_chats;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1137 while (bcs) {
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1138 chat = jid_new(j->p, bcs->data);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1139 if (!strcasecmp(b->name, chat->user))
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1140 break;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1141 bcs = bcs->next;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1142 }
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1143 if (!bcs)
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1144 return;
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1145
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1146 x = xmlnode_new_tag("message");
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1147 if (!strchr(name, '@'))
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1148 realwho = g_strdup_printf("%s@%s", name, j->user->server);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1149 else
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1150 realwho = g_strdup(name);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1151 xmlnode_put_attrib(x, "to", realwho);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1152 g_free(realwho);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1153
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1154 y = xmlnode_insert_tag(x, "x");
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1155 xmlnode_put_attrib(y, "xmlns", "jabber:x:conference");
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1156 subject = g_strdup_printf("%s@%s", chat->user, chat->server);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1157 xmlnode_put_attrib(y, "jid", subject);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1158 g_free(subject);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1159
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1160 if (message && strlen(message)) {
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1161 y = xmlnode_insert_tag(x, "body");
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1162 xmlnode_insert_cdata(y, message, -1);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1163 }
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1164
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1165 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1166 xmlnode_free(x);
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1167 }
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1168
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1169 static void jabber_chat_leave(struct gaim_connection *gc, int id)
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1170 {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1171 GSList *bcs = gc->buddy_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1172 struct conversation *b;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1173 struct jabber_data *jd = gc->proto_data;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1174 gjconn j = jd->jc;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1175 jid chat;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1176 xmlnode x;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1177
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1178 while (bcs) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1179 b = bcs->data;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1180 if (id == b->id)
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1181 break;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1182 bcs = bcs->next;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1183 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1184 if (!bcs)
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1185 return;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1186
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1187 bcs = jd->existing_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1188 while (bcs) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1189 chat = jid_new(j->p, bcs->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1190 if (!strcasecmp(b->name, chat->user))
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1191 break;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1192 bcs = bcs->next;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1193 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1194 if (!bcs)
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1195 return;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1196
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1197 x = jutil_presnew(0, bcs->data, NULL);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1198 xmlnode_put_attrib(x, "type", "unavailable");
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1199 gjab_send(j, x);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1200 xmlnode_free(x);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1201 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1202
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1203 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
1204 {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1205 GSList *bcs = gc->buddy_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1206 struct conversation *b;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1207 struct jabber_data *jd = gc->proto_data;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1208 gjconn j = jd->jc;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1209 jid chat;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1210 xmlnode x, y;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1211 char *chatname;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1212
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1213 while (bcs) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1214 b = bcs->data;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1215 if (id == b->id)
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1216 break;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1217 bcs = bcs->next;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1218 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1219 if (!bcs)
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1220 return;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1221
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1222 bcs = jd->existing_chats;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1223 while (bcs) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1224 chat = jid_new(j->p, bcs->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1225 if (!strcasecmp(b->name, chat->user))
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1226 break;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1227 bcs = bcs->next;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1228 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1229 if (!bcs)
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1230 return;
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1231
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1232 x = xmlnode_new_tag("message");
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1233 xmlnode_put_attrib(x, "from", bcs->data);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1234 chatname = g_strdup_printf("%s@%s", chat->user, chat->server);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1235 xmlnode_put_attrib(x, "to", chatname);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1236 g_free(chatname);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1237 xmlnode_put_attrib(x, "type", "groupchat");
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1238
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1239 if (message && strlen(message)) {
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1240 y = xmlnode_insert_tag(x, "body");
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1241 xmlnode_insert_cdata(y, message, -1);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1242 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1243
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1244 gjab_send(((struct jabber_data *)gc->proto_data)->jc, x);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1245 xmlnode_free(x);
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1246 }
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1247
1642
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1248 static GtkWidget *newname = NULL;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1249 static GtkWidget *newpass1 = NULL;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1250 static GtkWidget *newpass2 = NULL;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1251 static GtkWidget *newserv = NULL;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1252 static jconn regjconn = NULL;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1253 static int reginpa = 0;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1254
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1255 static void newdes()
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1256 {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1257 newname = newpass1 = newpass2 = newserv = NULL;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1258 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1259
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1260 static void jabber_draw_new_user(GtkWidget *box)
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1261 {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1262 GtkWidget *hbox;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1263 GtkWidget *label;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1264
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1265 if (newname)
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1266 return;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1267
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1268 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
1269 "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
1270 "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
1271 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1272 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1273 gtk_widget_show(label);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1274
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1275 hbox = gtk_hbox_new(FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1276 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1277 gtk_widget_show(hbox);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1278
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1279 label = gtk_label_new("Username:");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1280 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1281 gtk_widget_show(label);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1282
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1283 newname = gtk_entry_new();
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1284 gtk_box_pack_end(GTK_BOX(hbox), newname, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1285 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
1286 gtk_widget_show(newname);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1287
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1288 hbox = gtk_hbox_new(FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1289 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1290 gtk_widget_show(hbox);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1291
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1292 label = gtk_label_new("Password:");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1293 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1294 gtk_widget_show(label);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1295
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1296 newpass1 = gtk_entry_new();
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1297 gtk_box_pack_end(GTK_BOX(hbox), newpass1, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1298 gtk_entry_set_visibility(GTK_ENTRY(newpass1), FALSE);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1299 gtk_widget_show(newpass1);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1300
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1301 hbox = gtk_hbox_new(FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1302 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1303 gtk_widget_show(hbox);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1304
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1305 label = gtk_label_new("Confirm:");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1306 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1307 gtk_widget_show(label);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1308
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1309 newpass2 = gtk_entry_new();
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1310 gtk_box_pack_end(GTK_BOX(hbox), newpass2, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1311 gtk_entry_set_visibility(GTK_ENTRY(newpass2), FALSE);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1312 gtk_widget_show(newpass2);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1313
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1314 hbox = gtk_hbox_new(FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1315 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1316 gtk_widget_show(hbox);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1317
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1318 label = gtk_label_new("Server:");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1319 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1320 gtk_widget_show(label);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1321
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1322 newserv = gtk_entry_new();
1644
fb1741bc3bd0 [gaim-migrate @ 1654]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1642
diff changeset
1323 gtk_entry_set_text(GTK_ENTRY(newserv), "jabber.org");
1642
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1324 gtk_box_pack_end(GTK_BOX(hbox), newserv, FALSE, FALSE, 5);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1325 gtk_widget_show(newserv);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1326 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1327
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1328 static void regstate(jconn j, int state)
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1329 {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1330 static int catch = 0;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1331 switch (state) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1332 case JCONN_STATE_OFF:
1696
c6390c52caca [gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1688
diff changeset
1333 gdk_input_remove(reginpa);
c6390c52caca [gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1688
diff changeset
1334 reginpa = 0;
c6390c52caca [gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1688
diff changeset
1335 jab_delete(j);
1642
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1336 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1337 case JCONN_STATE_CONNECTED:
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1338 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1339 case JCONN_STATE_ON:
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1340 if (catch)
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1341 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1342 catch = 1;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1343 jab_reg(regjconn);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1344 catch = 0;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1345 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1346 case JCONN_STATE_AUTH:
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1347 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1348 default:
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1349 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1350 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1351 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1352
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1353 static void regpacket(jconn j, jpacket p)
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1354 {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1355 static int here = 0;
1696
c6390c52caca [gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1688
diff changeset
1356 g_print("here\n");
1642
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1357 switch (p->type) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1358 case JPACKET_MESSAGE:
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1359 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1360 case JPACKET_PRESENCE:
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1361 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1362 case JPACKET_IQ:
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1363 if (jpacket_subtype(p) == JPACKET__RESULT) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1364 xmlnode x, y, z;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1365 char *user, *id;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1366
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1367 if (here == 2) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1368 struct aim_user *u;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1369 user = g_strdup(jid_full(j->user));
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1370 regjconn = NULL;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1371 here = 0;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1372 u = new_user(user, PROTO_JABBER, OPT_USR_REM_PASS);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1373 g_free(user);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1374 g_snprintf(u->password, sizeof(u->password), "%s", j->pass);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1375 save_prefs();
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1376 xmlnode_free(p->x);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1377 do_error_dialog("Registration successful! Your account has been"
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1378 " added to the Account Editor.", "Jabber "
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1379 "Registration");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1380 gtk_entry_set_text(GTK_ENTRY(newname), "");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1381 gtk_entry_set_text(GTK_ENTRY(newpass1), "");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1382 gtk_entry_set_text(GTK_ENTRY(newpass2), "");
1696
c6390c52caca [gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1688
diff changeset
1383 g_print("reg\n");
1642
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1384 return;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1385 } else if (here == 1) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1386 x = jutil_iqnew(JPACKET__SET, NS_AUTH);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1387 here = 2;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1388 } else if (here == 0) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1389 here = 1;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1390 x = jutil_iqnew(JPACKET__GET, NS_AUTH);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1391 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1392
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1393 id = jab_getid(j);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1394 xmlnode_put_attrib(x, "id", id);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1395 y = xmlnode_get_tag(x, "query");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1396
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1397 user = j->user->user;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1398 if (user)
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1399 {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1400 z = xmlnode_insert_tag(y, "username");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1401 xmlnode_insert_cdata(z, user, -1);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1402 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1403
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1404 if (here == 2) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1405 z = xmlnode_insert_tag(y, "resource");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1406 xmlnode_insert_cdata(z, j->user->resource, -1);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1407 z = xmlnode_insert_tag(y, "password");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1408 xmlnode_insert_cdata(z, j->pass, -1);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1409 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1410
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1411 jab_send(j, x);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1412 xmlnode_free(x);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1413 } else if (jpacket_subtype(p) == JPACKET__ERROR) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1414 xmlnode x = xmlnode_get_tag(p->x, "error");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1415 if (x) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1416 char buf[8192];
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1417 g_snprintf(buf, sizeof(buf), "Registration failed: %d %s",
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1418 atoi(xmlnode_get_attrib(x, "code")),
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1419 xmlnode_get_data(xmlnode_get_firstchild(x)));
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1420 do_error_dialog(buf, "Jabber Registration");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1421 } else {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1422 do_error_dialog("Registration failed", "Jabber Registration");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1423 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1424 regjconn = NULL;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1425 xmlnode_free(p->x);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1426 here = 0;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1427 return;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1428 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1429 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1430 case JPACKET_S10N:
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1431 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1432 default:
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1433 break;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1434 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1435
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1436 xmlnode_free(p->x);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1437 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1438
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1439 static void regjcall(gpointer data, gint source, GdkInputCondition cond)
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1440 {
1696
c6390c52caca [gaim-migrate @ 1706]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1688
diff changeset
1441 gjab_recv((gjconn)regjconn);
1642
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1442 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1443
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1444 static void jabber_do_new_user()
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1445 {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1446 char *name, *pass1, *pass2, *serv;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1447 char *user;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1448
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1449 if (!newname || regjconn)
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1450 return;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1451
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1452 pass1 = gtk_entry_get_text(GTK_ENTRY(newpass1));
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1453 pass2 = gtk_entry_get_text(GTK_ENTRY(newpass2));
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1454 if (pass1[0] == 0 || pass2[0] == 0) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1455 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
1456 "Registration error");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1457 return;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1458 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1459 if (strcmp(pass1, pass2)) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1460 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
1461 "Registration error");
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1462 return;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1463 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1464 name = gtk_entry_get_text(GTK_ENTRY(newname));
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1465 serv = gtk_entry_get_text(GTK_ENTRY(newserv));
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1466 if (name[0] == 0 || serv[0] == 0) {
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1467 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
1468 return;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1469 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1470
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1471 user = g_strdup_printf("%s@%s/GAIM", name, serv);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1472 regjconn = jab_new(user, pass1);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1473 g_free(user);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1474
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1475 jab_state_handler(regjconn, regstate);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1476 jab_packet_handler(regjconn, regpacket);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1477
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1478 jab_start(regjconn);
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1479 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
1480 }
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1481
1713
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1482 static char *jabber_normalize(const char *s)
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1483 {
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1484 static char buf[BUF_LEN];
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1485 char *t, *u;
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1486 int x = 0;
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1487
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1488 g_return_val_if_fail((s != NULL), NULL);
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1489
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1490 u = t = g_strdup(s);
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1491
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1492 g_strdown(t);
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1493
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1494 while (*t && (x < BUF_LEN - 1)) {
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1495 if (*t != ' ')
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1496 buf[x++] = *t;
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1497 t++;
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1498 }
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1499 buf[x] = '\0';
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1500 g_free(u);
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1501
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1502 if (!strchr(buf, '@')) {
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1503 strcat(buf, "@jabber.org"); /* this isn't always right, but eh */
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1504 } else if ((u = strchr(strchr(buf, '@'), '/')) != NULL) {
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1505 *u = '\0';
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1506 }
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1507
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1508 return buf;
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1509 }
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1510
1758
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1511 static GList *jabber_away_states() {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1512 GList *m = NULL;
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1513
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1514 m = g_list_append(m, "Online");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1515 m = g_list_append(m, "Chatty");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1516 m = g_list_append(m, "Away");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1517 m = g_list_append(m, "Extended Away");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1518 m = g_list_append(m, "Do Not Disturb");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1519
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1520 return m;
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1521 }
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1522
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1523 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
1524 {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1525 xmlnode x, y;
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1526 struct jabber_data *jd = gc->proto_data;
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1527 gjconn j = jd->jc;
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1528
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1529 gc->away = NULL; /* never send an auto-response */
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1530
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1531 x = xmlnode_new_tag("presence");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1532
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1533 if (!strcmp(state, GAIM_AWAY_CUSTOM)) {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1534 /* oh goody. Gaim is telling us what to do. */
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1535 if (message) {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1536 /* Gaim wants us to be away */
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1537 y = xmlnode_insert_tag(x, "show");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1538 xmlnode_insert_cdata(y, "away", -1);
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1539 y = xmlnode_insert_tag(x, "status");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1540 xmlnode_insert_cdata(y, message, -1);
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1541 gc->away = "";
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1542 } else {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1543 /* Gaim wants us to not be away */
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1544 /* 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
1545 }
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1546 } else {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1547 /* 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
1548 if (!strcmp(state, "Online")) {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1549 /* once again, we don't have to put anything here */
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1550 } else if (!strcmp(state, "Chatty")) {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1551 y = xmlnode_insert_tag(x, "show");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1552 xmlnode_insert_cdata(y, "chat", -1);
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1553 } else if (!strcmp(state, "Away")) {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1554 y = xmlnode_insert_tag(x, "show");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1555 xmlnode_insert_cdata(y, "away", -1);
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1556 gc->away = "";
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1557 } else if (!strcmp(state, "Extended Away")) {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1558 y = xmlnode_insert_tag(x, "show");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1559 xmlnode_insert_cdata(y, "xa", -1);
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1560 gc->away = "";
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1561 } else if (!strcmp(state, "Do Not Disturb")) {
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1562 y = xmlnode_insert_tag(x, "show");
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1563 xmlnode_insert_cdata(y, "dnd", -1);
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1564 gc->away = "";
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1565 }
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1566 }
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1567
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1568 gjab_send(j, x);
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1569 xmlnode_free(x);
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1570 }
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1571
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1572 static struct prpl *my_protocol = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1573
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1574 void Jabber_init(struct prpl *ret)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1575 {
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1576 /* the NULL's aren't required but they're nice to have */
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1577 ret->protocol = PROTO_JABBER;
1772
896432d66303 [gaim-migrate @ 1782]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1771
diff changeset
1578 ret->options = OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_CHAT_TOPIC;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1579 ret->name = jabber_name;
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1580 ret->list_icon = jabber_list_icon;
1758
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1581 ret->away_states = jabber_away_states;
1499
de0b946e86a4 [gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1485
diff changeset
1582 ret->buddy_menu = NULL;
1331
f48cb8ddca59 [gaim-migrate @ 1341]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1316
diff changeset
1583 ret->user_opts = NULL;
1642
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1584 ret->draw_new_user = jabber_draw_new_user;
b29f70d97062 [gaim-migrate @ 1652]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1624
diff changeset
1585 ret->do_new_user = jabber_do_new_user;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1586 ret->login = jabber_login;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1587 ret->close = jabber_close;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1588 ret->send_im = jabber_send_im;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1589 ret->set_info = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1590 ret->get_info = NULL;
1758
eb7b48eef4a3 [gaim-migrate @ 1768]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
1591 ret->set_away = jabber_set_away;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1592 ret->get_away_msg = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1593 ret->set_dir = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1594 ret->get_dir = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1595 ret->dir_search = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1596 ret->set_idle = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1597 ret->change_passwd = NULL;
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1598 ret->add_buddy = jabber_add_buddy;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1599 ret->add_buddies = NULL;
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1600 ret->remove_buddy = jabber_remove_buddy;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1601 ret->add_permit = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1602 ret->add_deny = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1603 ret->rem_permit = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1604 ret->rem_deny = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1605 ret->set_permit_deny = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1606 ret->warn = NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1607 ret->accept_chat = NULL;
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1608 ret->join_chat = jabber_join_chat;
1724
4104a30264b7 [gaim-migrate @ 1734]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1713
diff changeset
1609 ret->chat_invite = jabber_chat_invite;
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1610 ret->chat_leave = jabber_chat_leave;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1611 ret->chat_whisper = NULL;
1466
1a24237f5865 [gaim-migrate @ 1476]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1443
diff changeset
1612 ret->chat_send = jabber_chat_send;
1312
f22f57ed13e9 [gaim-migrate @ 1322]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1311
diff changeset
1613 ret->keepalive = NULL;
1713
14caa7df478c [gaim-migrate @ 1723]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1707
diff changeset
1614 ret->normalize = jabber_normalize;
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1615
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1616 my_protocol = ret;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1617 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1618
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1619 char *gaim_plugin_init(GModule *handle)
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1620 {
1443
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1363
diff changeset
1621 load_protocol(Jabber_init, sizeof(struct prpl));
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1622 return NULL;
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1623 }
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1624
1345
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1625 void gaim_plugin_remove()
d6e6fcaa1f39 [gaim-migrate @ 1355]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1344
diff changeset
1626 {
1311
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1627 struct prpl *p = find_prpl(PROTO_JABBER);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1628 if (p == my_protocol)
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1629 unload_protocol(p);
338b8ac6bdab [gaim-migrate @ 1321]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1630 }