annotate src/protocols/jabber/jabber.c @ 6036:547ba881bc7e

[gaim-migrate @ 6486] Fix the --login=[NAME] command line argument. Fix the password prompt when signing on an account with no password set. I made some similar changes that probably fix problems with the filectl plugin, using gaim-remote to sign on an account, and signing on an account via perl script. (The change is calling gaim_account_connect() instead of serv_login().) Fix a silly compiler warning. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 05 Jul 2003 22:24:57 +0000
parents 3b4f94adc7d4
children d8cd876e613e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 * gaim
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * (at your option) any later version.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * GNU General Public License for more details.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
22 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
23
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
24 #ifdef _WIN32
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
25 # include "utsname.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #endif
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
28 #include "account.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
29 #include "accountopt.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
30 #include "conversation.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
31 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
32 #include "ft.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
33 #include "multi.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
34 #include "notify.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
35 #include "prpl.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
36 #include "request.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
37 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
38
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
39 /* XXX */
4608
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4591
diff changeset
40 #include "gaim.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
41
2232
14e8978f86bb [gaim-migrate @ 2242]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
42 #ifdef MAX
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
43 # undef MAX
2232
14e8978f86bb [gaim-migrate @ 2242]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
44 #endif
14e8978f86bb [gaim-migrate @ 2242]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
45 #ifdef MIN
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
46 # undef MIN
2232
14e8978f86bb [gaim-migrate @ 2242]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
47 #endif
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
48
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #include "jabber.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 #include "proxy.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
52 static GaimPlugin *my_protocol = NULL;
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
53
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 /* The priv member of gjconn's is a gaim_connection for now. */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
55 #define GJ_GC(x) ((GaimConnection *)(x)->priv)
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
56 /* Confused? That makes three of us. -Robot101 */
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
57 #define GC_GJ(x) ((gjconn)((struct jabber_data *)(x)->proto_data)->gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
5894
8b1b660519f6 [gaim-migrate @ 6326]
Mark Doliner <mark@kingant.net>
parents: 5872
diff changeset
59 #define JABBER_CONNECT_STEPS 5
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
60
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 #define IQID_AUTH "__AUTH__"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 #define IQ_NONE -1
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 #define IQ_AUTH 0
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 #define IQ_ROSTER 1
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
3259
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
67 #define UC_AWAY (0x02 | UC_UNAVAILABLE)
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
68 #define UC_CHAT 0x04
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
69 #define UC_XA (0x08 | UC_UNAVAILABLE)
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
70 #define UC_DND (0x10 | UC_UNAVAILABLE)
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
71 #define UC_ERROR (0x20 | UC_UNAVAILABLE)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72
4917
c0c6efda8151 [gaim-migrate @ 5251]
Sean Egan <seanegan@gmail.com>
parents: 4916
diff changeset
73 #define DEFAULT_SERVER "jabber.org"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 #define DEFAULT_GROUPCHAT "conference.jabber.org"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 #define DEFAULT_PORT 5222
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 #define USEROPT_PORT 0
4436
83260179de90 [gaim-migrate @ 4711]
Nathan Walp <nwalp@pidgin.im>
parents: 4366
diff changeset
78 #define USEROPT_CONN_SERVER 1
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
80 #define JABBER_TYPING_NOTIFY_INT 15 /* Delay (in seconds) between sending typing notifications */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
81
4450
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
82 #define JABBER_KEEPALIVE_STRING " \t "
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
83
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
84 /*
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
85 * Note: "was_connected" may seem redundant, but it was needed and I
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
86 * didn't want to touch the Jabber state stuff not specific to Gaim.
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
87 */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 typedef struct gjconn_struct {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 /* Core structure */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 pool p; /* Memory allocation pool */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 int state; /* Connection state flag */
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
92 int was_connected; /* We were once connected */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 int fd; /* Connection file descriptor */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 jid user; /* User info */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 char *pass; /* User passwd */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 /* Stream stuff */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 int id; /* id counter for jab_getid() function */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 char idbuf[9]; /* temporary storage for jab_getid() */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 char *sid; /* stream id from server, for digest auth */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 XML_Parser parser; /* Parser instance */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 xmlnode current; /* Current node in parsing instance.. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 /* Event callback ptrs */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
105 void (*on_state)(struct gjconn_struct *gjc, int state);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
106 void (*on_packet)(struct gjconn_struct *gjc, jpacket p);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
107
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
108 GHashTable *queries; /* query tracker */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 void *priv;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 } *gjconn, gjconn_struct;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
114 typedef void (*gjconn_state_h)(gjconn gjc, int state);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
115 typedef void (*gjconn_packet_h)(gjconn gjc, jpacket p);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 static gjconn gjab_new(char *user, char *pass, void *priv);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
118 static void gjab_delete(gjconn gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
119 static void gjab_state_handler(gjconn gjc, gjconn_state_h h);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
120 static void gjab_packet_handler(gjconn gjc, gjconn_packet_h h);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
121 static void gjab_start(gjconn gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
122 static void gjab_stop(gjconn gjc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 /*
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
124 static int gjab_getfd(gjconn gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
125 static jid gjab_getjid(gjconn gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
126 static char *gjab_getsid(gjconn gjc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
128 static char *gjab_getid(gjconn gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
129 static void gjab_send(gjconn gjc, xmlnode x);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
130 static void gjab_send_raw(gjconn gjc, const char *str);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
131 static void gjab_recv(gjconn gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
132 static void gjab_auth(gjconn gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
133
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
134 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
135 * It is *this* to which we point the gaim_connection proto_data
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
136 */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 struct jabber_data {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
138 gjconn gjc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 gboolean did_import;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
140 GSList *chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 time_t idle;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
142 GHashTable *buddies;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
143 GSList *file_transfers;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
146 /*
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
147 * Used in jabber_buddy_data.invisible, below
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
148 */
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
149 #define JABBER_NOT_INVIS 0x00
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
150 #define JABBER_SERV_INVIS 0x01 /* Invisible set on server */
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
151 #define JABBER_BUD_INVIS 0x02 /* Invisible set on buddy */
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
152
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
153 /*
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
154 * Used in jabber_buddy_data.subscription, below
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
155 */
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
156 #define JABBER_SUB_NONE 0x0
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
157 #define JABBER_SUB_PENDING 0x1
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
158 #define JABBER_SUB_TO 0x2
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
159 #define JABBER_SUB_FROM 0x4
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
160 #define JABBER_SUB_BOTH (JABBER_SUB_TO | JABBER_SUB_FROM)
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
161
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
162
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
163 /*
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
164 * It is *this* to which we point the buddy proto_data
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
165 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
166 struct jabber_buddy_data {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
167 GSList *resources;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
168 char *error_msg;
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
169 unsigned invisible; /* We've set presence type invisible for this buddy */
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
170 unsigned subscription; /* subscription type for this buddy */
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
171 };
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
172
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
173 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
174 * per-resource info
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
175 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
176 typedef struct jabber_resource_info {
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
177 char *name;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
178 int priority;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
179 int state;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
180 char *away_msg;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
181 char *thread_id;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
182 gboolean has_composing;
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
183 gboolean has_xhtml;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
184 } *jab_res_info;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
185
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
186 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
187 * For our own jid handling
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
188 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
189 * We do our own so we can cleanly parse buddy names
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
190 * (user@server/resource) and rid ourselves of the
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
191 * struct when we're done with it. The Jabber lib
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
192 * structs last the life of the pool--we frequently
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
193 * don't want that.
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
194 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
195 * We use the real jid structs so we can make use of
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
196 * jid_safe(), jid_cmp() and some others.
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
197 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
198 * BE CAREFUL using the Jabber lib routines.
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
199 * Many of them assume pool use and are not
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
200 * amenable to use with our own!
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
201 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
202 * We give them special names so we know, throughout
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
203 * the code, that they're not alloc'd out of pool
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
204 * memory and we can, and must, dispose of them when
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
205 * we're done with 'em.
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
206 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
207 #define gaim_jid_struct jid_struct
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
208 typedef struct gaim_jid_struct *gaim_jid;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
209
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
210 /*
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
211 * Jabber "chat group" info. Pointers to these go in jabber_data
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
212 * pending and existing chats lists.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
213 */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 struct jabber_chat {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
215 gaim_jid gjid;
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
216 GaimConnection *gc;
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
217 GaimConversation *b;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 int id;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
219 int state;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
222 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
223 * Jabber chat states...
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
224 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
225 * Note: due to a bug in one version of the Jabber server, subscriptions
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
226 * to chat groups aren't (always?) properly removed at the server. The
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
227 * result is clients receive Jabber "presence" notifications for JIDs
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
228 * they no longer care about. The problem with such vestigial notifies is
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
229 * that we really have no way of telling if it's vestigial or if it's a
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
230 * valid "buddy" presence notification. So we keep jabber_chat structs
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
231 * around after leaving a chat group and simply mark them "closed." That
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
232 * way we can test for such errant presence notifications. I.e.: if we
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
233 * get a presence notfication from a JID that matches a chat group JID,
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
234 * we disregard it.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
235 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
236 #define JCS_PENDING 1 /* pending */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
237 #define JCS_ACTIVE 2 /* active */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
238 #define JCS_CLOSED 3 /* closed */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
239
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
240
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
241 #define STATE_EVT(arg) if(gjc->on_state) { (gjc->on_state)(gjc, (arg) ); }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
242
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
243 static void jabber_handlevcard(gjconn, xmlnode, char *);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
245 static char *jabber_normalize(const char *s);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
246
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 static char *create_valid_jid(const char *given, char *server, char *resource)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 char *valid;
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
250 char *tmp;
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
251
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
252 if (!(tmp = strchr(given, '@')))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 valid = g_strdup_printf("%s@%s/%s", given, server, resource);
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
254 else if (!strchr(tmp, '/'))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 valid = g_strdup_printf("%s/%s", given, resource);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 valid = g_strdup(given);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 return valid;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261
4915
0230df73f56a [gaim-migrate @ 5249]
Luke Schierer <lschiere@pidgin.im>
parents: 4874
diff changeset
262
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
263 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
264 * Dispose of a gaim_jid_struct
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
265 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
266 static void gaim_jid_free(gaim_jid gjid)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
267 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
268 if(gjid) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
269 if(gjid->resource)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
270 free(gjid->resource);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
271 if(gjid->user)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
272 free(gjid->user);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
273 if(gjid->server)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
274 free(gjid->server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
275 if(gjid->full)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
276 free(gjid->full);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
277 free(gjid);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
278 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
279 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
280
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
281 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
282 * Create a new gjid struct
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
283 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
284 * Unlike jid_new(), also creates "full."
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
285 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
286 * Shamelessly copied, in part, from jid.c: jid_new()
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
287 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
288 * Caller is responsible for freeing the space allocated by this via
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
289 * gaim_jid_free().
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
290 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
291 * JFIXME: Has a local declaration for jid.c:jid_safe(). I've put in a
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
292 * request to have that added to libjabber's lib.h file. (JSeymour)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
293 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
294 static gaim_jid gaim_jid_new(char *name)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
295 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
296 extern jid jid_safe(jid); /* *retch* */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
297
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
298 gaim_jid gjid = NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
299
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
300 if(name && strlen(name)) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
301 char *server, *resource, *type, *str;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
302 int full_len = 0;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
303
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
304 /* user@server/resource */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
305
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
306 str = strdup(name); /* we mangle a copy */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
307
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
308 gjid = calloc(1, sizeof(struct gaim_jid_struct));
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
309
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
310 if((resource = strstr(str, "/")) != NULL) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
311 *resource = '\0';
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
312 ++resource;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
313 if((full_len = strlen(resource)) > 0) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
314 gjid->resource = strdup(resource);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
315 ++full_len; /* for later "/" addition */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
316 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
317 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
318 resource = str + strlen(str); /* point to end */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
319 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
320
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
321 type = strstr(str, ":");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
322 if(type != NULL && type < resource) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
323 *type = '\0';
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
324 ++type;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
325 str = type; /* ignore the type: prefix */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
326 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
327
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
328 server = strstr(str, "@");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
329
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
330 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
331 * if there's no @, it's just the server address
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
332 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
333 if(server == NULL || server > resource) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
334 gjid->server = strdup(str);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
335 full_len += strlen(str);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
336 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
337 *server = '\0';
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
338 ++server;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
339 gjid->server = strdup(server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
340 full_len += strlen(server) + 1; /* account for later "@" */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
341 if(strlen(str) > 0) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
342 gjid->user = strdup(str);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
343 full_len += strlen(str);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
344 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
345 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
346
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
347 free(str);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
348
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
349 if(!jid_safe(gjid)) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
350 gaim_jid_free(gjid);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
351 gjid = NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
352 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
353 if(full_len) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
354 char *s = gjid->full = malloc(++full_len);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
355
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
356 if(gjid->user) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
357 strcpy(s, gjid->user);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
358 s += strlen(gjid->user);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
359 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
360 if(gjid->server) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
361 if(s > gjid->full)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
362 *(s++) = '@';
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
363 strcpy(s, gjid->server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
364 s += strlen(gjid->server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
365 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
366 if(gjid->resource) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
367 *(s++) = '/';
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
368 strcpy(s, gjid->resource);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
369 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
370 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
371 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
372 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
373
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
374 return gjid;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
375 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
376
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
377 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
378 * Get a "username@server" from unadorned "username"
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
379 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
380 * If there's no "@server" part and "who" doesn't match the
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
381 * gjconn server (which would indicate that "who" *is* the
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
382 * server in case of server messages), the gjconn server is
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
383 * appended.
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
384 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
385 * If incl_resource is TRUE (non-0), the returned string
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
386 * includes the "/resource" part (if it exists), otherwise not.
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
387 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
388 * Allocates space for returned string. Caller is
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
389 * responsible for freeing it with g_free().
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
390 *
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
391 * If "gjid" is non-null, sets that as well. Caller is
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
392 * reponsible for freeing that via gaim_jid_free() when done
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
393 * with it.
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
394 */
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3456
diff changeset
395 static gchar *get_realwho(gjconn gjc, const char *who, int incl_resource, gaim_jid *gjid)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
396 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
397 gaim_jid my_gjid;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
398 gchar *my_who;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
399 gchar *realwho = NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
400
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
401 if(!(who && who[0])) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
402 return NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
403 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
404
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
405 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
406 * Bare username and "username" not the server itself?
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
407 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
408 if(!strchr(who, '@') && strcasecmp(who, gjc->user->server)) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
409 my_who = g_strdup_printf("%s@%s", who, gjc->user->server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
410 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
411 my_who = g_strdup(who);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
412 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
413
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
414 if((my_gjid = gaim_jid_new(my_who)) != NULL) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
415 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
416 * If there's no "user" part, "who" was just the server or perhaps a transport (?)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
417 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
418 if(my_gjid->user) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
419 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
420 * Include "/resource" bit?
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
421 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
422 if(incl_resource) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
423 realwho = g_strdup(my_gjid->full);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
424 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
425 realwho = g_strdup_printf("%s@%s", my_gjid->user, my_gjid->server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
426 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
427 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
428 realwho = g_strdup(my_gjid->server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
429 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
430 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
431
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
432 g_free(my_who);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
433
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
434 if(gjid) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
435 *gjid = my_gjid;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
436 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
437 gaim_jid_free(my_gjid);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
438 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
439
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
440 return realwho;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
441 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
442
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 static gjconn gjab_new(char *user, char *pass, void *priv)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 pool p;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
446 gjconn gjc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 if (!user)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 return (NULL);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 p = pool_new();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 if (!p)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 return (NULL);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
454 gjc = pmalloc_x(p, sizeof(gjconn_struct), 0);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
455 if (!gjc) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
456 pool_free(p); /* no need for this anymore! */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 return (NULL);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
458 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
459 gjc->p = p;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
460
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
461 if((gjc->user = jid_new(p, user)) == NULL) {
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
462 pool_free(p); /* no need for this anymore! */
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
463 return (NULL);
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
464 }
3257
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
465
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
466 gjc->pass = strdup(pass);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
467
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
468 gjc->state = JCONN_STATE_OFF;
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
469 gjc->was_connected = 0;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
470 gjc->id = 1;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
471 gjc->fd = -1;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
472
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
473 gjc->priv = priv;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
474
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
475 return gjc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
478 static void gjab_delete(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
480 if (!gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
483 gjab_stop(gjc);
3257
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
484 free(gjc->pass);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
485 pool_free(gjc->p);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
488 static void gjab_state_handler(gjconn gjc, gjconn_state_h h)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
490 if (!gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
493 gjc->on_state = h;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
496 static void gjab_packet_handler(gjconn gjc, gjconn_packet_h h)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
498 if (!gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
501 gjc->on_packet = h;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
504 static void gjab_stop(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
506 if (!gjc || gjc->state == JCONN_STATE_OFF)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
509 gjab_send_raw(gjc, "</stream:stream>");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
510 gjc->state = JCONN_STATE_OFF;
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
511 gjc->was_connected = 0;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
512 close(gjc->fd);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
513 gjc->fd = -1;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
514 XML_ParserFree(gjc->parser);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
515 gjc->parser = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 /*
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
519 static int gjab_getfd(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
521 if (gjc)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
522 return gjc->fd;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524 return -1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
525 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
527 static jid gjab_getjid(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
528 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
529 if (gjc)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
530 return (gjc->user);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
532 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
535 static char *gjab_getsid(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
537 if (gjc)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
538 return (gjc->sid);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
544 static char *gjab_getid(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
546 snprintf(gjc->idbuf, 8, "%d", gjc->id++);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
547 return &gjc->idbuf[0];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
550 static void gjab_send(gjconn gjc, xmlnode x)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
552 if (gjc && gjc->state != JCONN_STATE_OFF) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 char *buf = xmlnode2str(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 if (buf)
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
555 #ifndef _WIN32
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
556 write(gjc->fd, buf, strlen(buf));
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
557 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
558 send(gjc->fd, buf, strlen(buf), 0);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
559 #endif
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
560 gaim_debug(GAIM_DEBUG_MISC, "jabber", "gjab_send: %s\n", buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
562 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
564 static void gjab_send_raw(gjconn gjc, const char *str)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
566 if (gjc && gjc->state != JCONN_STATE_OFF) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
567 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
568 * JFIXME: No error detection?!?!
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
569 */
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
570 #ifndef _WIN32
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
571 if(write(gjc->fd, str, strlen(str)) < 0) {
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
572 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
573 if(send(gjc->fd, str, strlen(str), 0) < 0) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
574 #endif
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
575 fprintf(stderr, "DBG: Problem sending. Error: %d\n", errno);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
576 fflush(stderr);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
577 }
4450
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
578 /* printing keepalives to the debug window is really annoying */
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
579 if(strcmp(str, JABBER_KEEPALIVE_STRING))
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
580 gaim_debug(GAIM_DEBUG_MISC, "jabber", "gjab_send_raw: %s\n", str);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
582 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
584 static void gjab_reqroster(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
586 xmlnode x;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
588 x = jutil_iqnew(JPACKET__GET, NS_ROSTER);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
589 xmlnode_put_attrib(x, "id", gjab_getid(gjc));
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
590
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
591 gjab_send(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
592 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
593 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
594
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
595 static void gjab_reqauth(gjconn gjc)
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
596 {
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
597 xmlnode x, y, z;
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
598 char *user;
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
599
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
600 if (!gjc)
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
601 return;
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
602
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
603 x = jutil_iqnew(JPACKET__GET, NS_AUTH);
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
604 xmlnode_put_attrib(x, "id", IQID_AUTH);
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
605 y = xmlnode_get_tag(x, "query");
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
606
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
607 user = gjc->user->user;
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
608
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
609 if (user) {
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
610 z = xmlnode_insert_tag(y, "username");
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
611 xmlnode_insert_cdata(z, user, -1);
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
612 }
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
613
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
614 gjab_send(gjc, x);
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
615 xmlnode_free(x);
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
616 }
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
617
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
618 static void gjab_auth(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
619 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
620 xmlnode x, y, z;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621 char *hash, *user;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
623 if (!gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 x = jutil_iqnew(JPACKET__SET, NS_AUTH);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627 xmlnode_put_attrib(x, "id", IQID_AUTH);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
628 y = xmlnode_get_tag(x, "query");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
630 user = gjc->user->user;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
631
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 if (user) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633 z = xmlnode_insert_tag(y, "username");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634 xmlnode_insert_cdata(z, user, -1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637 z = xmlnode_insert_tag(y, "resource");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
638 xmlnode_insert_cdata(z, gjc->user->resource, -1);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
639
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
640 if (gjc->sid) {
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
641 gaim_debug(GAIM_DEBUG_MISC, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
642 "digest authentication (sid %s)\n", gjc->sid);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 z = xmlnode_insert_tag(y, "digest");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
644 hash = pmalloc(x->p, strlen(gjc->sid) + strlen(gjc->pass) + 1);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
645 strcpy(hash, gjc->sid);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
646 strcat(hash, gjc->pass);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647 hash = shahash(hash);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648 xmlnode_insert_cdata(z, hash, 40);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 z = xmlnode_insert_tag(y, "password");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
651 xmlnode_insert_cdata(z, gjc->pass, -1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
654 gjab_send(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
660 static void gjab_recv(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 static char buf[4096];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 int len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
665 if (!gjc || gjc->state == JCONN_STATE_OFF)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 return;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
667 #ifndef _WIN32
3234
6a96436a542a [gaim-migrate @ 3251]
Jim Seymour <jseymour>
parents: 3229
diff changeset
668 if ((len = read(gjc->fd, buf, sizeof(buf) - 1)) > 0) {
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
669 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
670 if ((len = recv(gjc->fd, buf, sizeof(buf) - 1, 0)) > 0) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
671 #endif
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
672 buf[len] = '\0';
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
673 gaim_debug(GAIM_DEBUG_MISC, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
674 "input (len %d): %s\n", len, buf);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
675 XML_Parse(gjc->parser, buf, len, 0);
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
676 } else if (len < 0 || errno != EAGAIN) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
677 STATE_EVT(JCONN_STATE_OFF)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
680
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
681 static void startElement(void *userdata, const char *name, const char **attribs)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683 xmlnode x;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
684 gjconn gjc = (gjconn) userdata;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
685
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
686 if (gjc->current) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687 /* Append the node to the current one */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
688 x = xmlnode_insert_tag(gjc->current, name);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 xmlnode_put_expat_attribs(x, attribs);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
691 gjc->current = x;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693 x = xmlnode_new_tag(name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694 xmlnode_put_expat_attribs(x, attribs);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695 if (strcmp(name, "stream:stream") == 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696 /* special case: name == stream:stream */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697 /* id attrib of stream is stored for digest auth */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
698 gjc->sid = g_strdup(xmlnode_get_attrib(x, "id"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699 /* STATE_EVT(JCONN_STATE_AUTH) */
2635
8c75e59e4bdf [gaim-migrate @ 2648]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2607
diff changeset
700 xmlnode_free(x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 } else {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
702 gjc->current = x;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
705 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
707 static void endElement(void *userdata, const char *name)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
708 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
709 gjconn gjc = (gjconn) userdata;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 xmlnode x;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711 jpacket p;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
712
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
713 if (gjc->current == NULL) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 /* we got </stream:stream> */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 STATE_EVT(JCONN_STATE_OFF)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
717 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
718
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
719 x = xmlnode_get_parent(gjc->current);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
720
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
721 if (!x) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
722 /* it is time to fire the event */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
723 p = jpacket_new(gjc->current);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
724
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
725 if (gjc->on_packet)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
726 (gjc->on_packet) (gjc, p);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 else
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
728 xmlnode_free(gjc->current);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
730
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
731 gjc->current = x;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
734 static void jabber_callback(gpointer data, gint source, GaimInputCondition condition)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
736 GaimConnection *gc = data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
737 struct jabber_data *jd = (struct jabber_data *)gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
739 gjab_recv(jd->gjc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 static void charData(void *userdata, const char *s, int slen)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
743 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
744 gjconn gjc = (gjconn) userdata;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
745
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
746 if (gjc->current)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
747 xmlnode_insert_cdata(gjc->current, s, slen);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
749
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
750 static void gjab_connected(gpointer data, gint source, GaimInputCondition cond)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
751 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
752 xmlnode x;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
753 char *t, *t2;
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
754 GaimConnection *gc = data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755 struct jabber_data *jd;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
756 gjconn gjc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757
5578
847ad796326d [gaim-migrate @ 5982]
Christian Hammond <chipx86@chipx86.com>
parents: 5572
diff changeset
758 if (!g_list_find(gaim_connections_get_all(), gc)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 close(source);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
761 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
763 jd = gc->proto_data;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
764 gjc = jd->gjc;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
765
4366
7ba9b56a8796 [gaim-migrate @ 4632]
Sean Egan <seanegan@gmail.com>
parents: 4359
diff changeset
766 gjc->fd = source;
2300
d2686f757d6e [gaim-migrate @ 2310]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
767
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
768 if (source == -1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
769 STATE_EVT(JCONN_STATE_OFF)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
770 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
771 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
773 gjc->state = JCONN_STATE_CONNECTED;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
774 STATE_EVT(JCONN_STATE_CONNECTED)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
775
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776 /* start stream */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
777 x = jutil_header(NS_CLIENT, gjc->user->server);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778 t = xmlnode2str(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779 /* this is ugly, we can create the string here instead of jutil_header */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
780 /* what do you think about it? -madcat */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781 t2 = strstr(t, "/>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 *t2++ = '>';
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783 *t2 = '\0';
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
784 gjab_send_raw(gjc, "<?xml version='1.0'?>");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
785 gjab_send_raw(gjc, t);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
788 gjc->state = JCONN_STATE_ON;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789 STATE_EVT(JCONN_STATE_ON);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
791 gc = GJ_GC(gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
792 gc->inpa = gaim_input_add(gjc->fd, GAIM_INPUT_READ, jabber_callback, gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
793 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
794
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
795 static void gjab_start(gjconn gjc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
796 {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
797 GaimAccount *account;
4366
7ba9b56a8796 [gaim-migrate @ 4632]
Sean Egan <seanegan@gmail.com>
parents: 4359
diff changeset
798 int port, rc;
5613
3d0a2b9f5a8e [gaim-migrate @ 6019]
Nathan Walp <nwalp@pidgin.im>
parents: 5599
diff changeset
799 const char *connect_server;
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
800 const char *server;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
801
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
802 if (!gjc || gjc->state != JCONN_STATE_OFF)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
803 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
804
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4452
diff changeset
805 account = GJ_GC(gjc)->account;
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
806 port = gaim_account_get_int(account, "port", DEFAULT_PORT);
5613
3d0a2b9f5a8e [gaim-migrate @ 6019]
Nathan Walp <nwalp@pidgin.im>
parents: 5599
diff changeset
807 connect_server = gaim_account_get_string(account, "connect_server", "");
3d0a2b9f5a8e [gaim-migrate @ 6019]
Nathan Walp <nwalp@pidgin.im>
parents: 5599
diff changeset
808 server = connect_server[0] ? connect_server : gjc->user->server;
3d0a2b9f5a8e [gaim-migrate @ 6019]
Nathan Walp <nwalp@pidgin.im>
parents: 5599
diff changeset
809
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
810
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
811 gjc->parser = XML_ParserCreate(NULL);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
812 XML_SetUserData(gjc->parser, (void *)gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
813 XML_SetElementHandler(gjc->parser, startElement, endElement);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
814 XML_SetCharacterDataHandler(gjc->parser, charData);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
815
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5679
diff changeset
816 rc = gaim_proxy_connect(account, server, port, gjab_connected, GJ_GC(gjc));
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4452
diff changeset
817 if (!account->gc || (rc != 0)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
818 STATE_EVT(JCONN_STATE_OFF)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
820 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
822
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
823 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
824 * Find chat by chat group name
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
825 */
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
826 static GaimConversation *find_chat(GaimConnection *gc, char *name)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
827 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828 GSList *bcs = gc->buddy_chats;
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
829 GaimConversation *b = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 char *chat = g_strdup(normalize(name));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 while (bcs) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833 b = bcs->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834 if (!strcasecmp(normalize(b->name), chat))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836 b = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837 bcs = bcs->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 g_free(chat);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841 return b;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
844 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
845 * Find chat by "chat id"
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
846 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
847 * Returns: 0 on success and jabber_chat pointer set
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
848 * or -EINVAL on error and jabber_chat pointer is
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
849 * undefined.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
850 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
851 * TBD: Slogging through the buddy_chats list seems
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
852 * redundant since the chat i.d. is mirrored in the
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
853 * jabber_chat struct list. But that's the way it
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
854 * was, so that's the way I'm leaving it--for now.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
855 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
856 static int jabber_find_chat_by_convo_id(GaimConnection *gc, int id, struct jabber_chat **jc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
857 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
858 GSList *bcs = gc->buddy_chats;
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
859 GaimConversation *b = NULL;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
860 struct jabber_data *jd = gc->proto_data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
861
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
862 *jc = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
863
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
864 while(bcs != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
865 b = bcs->data;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
866 if (id == gaim_chat_get_id(GAIM_CHAT(b)))
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
867 break;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
868 bcs = bcs->next;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
869 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
870
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
871 if (bcs != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
872 bcs = jd->chats;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
873 while (bcs != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
874 *jc = bcs->data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
875 if ((*jc)->state == JCS_ACTIVE && (*jc)->b == b)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
876 break;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
877 bcs = bcs->next;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
878 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
879 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
880
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
881 return(bcs == NULL? -EINVAL : 0);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
882 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
883
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
884 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
885 * Find any chat
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
886 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
887 static struct jabber_chat *find_any_chat(GaimConnection *gc, jid chat)
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
888 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
889 GSList *jcs = ((struct jabber_data *)gc->proto_data)->chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890 struct jabber_chat *jc = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
892 while (jcs) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
893 jc = jcs->data;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
894 if (!jid_cmpx(chat, jc->gjid, JID_USER | JID_SERVER))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896 jc = NULL;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
897 jcs = jcs->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
898 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900 return jc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
903
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
904 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
905 * Find existing/active Jabber chat
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
906 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
907 static struct jabber_chat *find_existing_chat(GaimConnection *gc, jid chat)
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
908 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
909 GSList *jcs = ((struct jabber_data *)gc->proto_data)->chats;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
910 struct jabber_chat *jc = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
911
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
912 while (jcs) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
913 jc = jcs->data;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
914 if (jc->state == JCS_ACTIVE && !jid_cmpx(chat, jc->gjid, JID_USER | JID_SERVER))
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
915 break;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
916 jc = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
917 jcs = jcs->next;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
918 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
919
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
920 return jc;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
921 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
922
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
923 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
924 * Find pending chat
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
925 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
926 static struct jabber_chat *find_pending_chat(GaimConnection *gc, jid chat)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
928 GSList *jcs = ((struct jabber_data *)gc->proto_data)->chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
929 struct jabber_chat *jc = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
930
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
931 while (jcs) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
932 jc = jcs->data;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
933 if (jc->state == JCS_PENDING && !jid_cmpx(chat, jc->gjid, JID_USER | JID_SERVER))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
934 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
935 jc = NULL;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
936 jcs = jcs->next;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
938
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
939 return jc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
940 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
941
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
942 static gboolean find_chat_buddy(GaimConversation *b, char *name)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
943 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
944 GList *m = gaim_chat_get_users(GAIM_CHAT(b));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
945
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
946 while (m) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
947 if (!strcmp(m->data, name))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
948 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
949 m = m->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
950 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
952 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
953 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
954
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
955 /*
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
956 * Remove a buddy from the (gaim) buddylist (if he's on it)
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
957 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
958 static void jabber_remove_gaim_buddy(GaimConnection *gc, const char *buddyname)
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
959 {
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
960 struct buddy *b;
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
961
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
962 if ((b = gaim_find_buddy(gc->account, buddyname)) != NULL) {
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
963 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
964 "removing buddy [1]: %s\n", buddyname);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
965 gaim_blist_remove_buddy(b);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4333
diff changeset
966 gaim_blist_save();
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
967 }
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
968 }
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
969
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
970 static void jabber_change_passwd(GaimConnection *gc, const char *old, const char *new)
3257
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
971 {
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
972 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
973
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
974 if(strcmp(old, gjc->pass))
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
975 {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
976 gaim_notify_error(gc, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
977 _("Unable to change password."),
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
978 _("The current password you entered is incorrect. "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
979 "Your password has not been changed."));
3257
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
980 }
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
981 else if(!strcmp(old, new))
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
982 {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
983 gaim_notify_error(gc, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
984 _("Unable to change password"),
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
985 _("The new password you entered is the same as "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
986 "your current password. "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
987 "Your password remains the same."));
3257
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
988 }
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
989 else
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
990 {
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
991 xmlnode x, y, z;
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
992 char *id;
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
993
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
994 x = jutil_iqnew(JPACKET__SET, NS_REGISTER);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
995 xmlnode_put_attrib(x, "to", gjc->user->server);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
996 y = xmlnode_get_tag(x, "query");
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
997 z = xmlnode_insert_tag(y, "username");
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
998 xmlnode_insert_cdata(z, gjc->user->user, -1);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
999 z = xmlnode_insert_tag(y, "password");
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1000 xmlnode_insert_cdata(z, new, -1);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1001
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1002 id = gjab_getid(gjc);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1003 xmlnode_put_attrib(x, "id", id);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1004
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1005 free(gjc->pass);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1006 gjc->pass = strdup(new);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1007
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1008 g_hash_table_insert(gjc->queries, g_strdup(id), g_strdup("change_password"));
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1009
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1010 gjab_send(gjc, x);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1011 xmlnode_free(x);
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1012 }
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
1013 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1014
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
1015 /*
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
1016 * Return pointer to jabber_buddy_data if buddy found. Create if necessary.
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
1017 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1018 static struct jabber_buddy_data* jabber_find_buddy(GaimConnection *gc, const char *buddy, gboolean create)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1019 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1020 struct jabber_data *jd = gc->proto_data;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1021 gpointer val;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1022 char *realwho;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1023
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1024 if((realwho = get_realwho(jd->gjc, buddy, FALSE, NULL)) == NULL)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1025 return NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1026
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1027 val = g_hash_table_lookup(jd->buddies, realwho);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1028 if(val) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1029 g_free(realwho);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1030 return (struct jabber_buddy_data *)val;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1031
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1032 } else if (create) {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1033 struct jabber_buddy_data *jbd = g_new0(struct jabber_buddy_data, 1);
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
1034 jbd->invisible = JABBER_NOT_INVIS;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1035 g_hash_table_insert(jd->buddies, g_strdup(realwho), jbd);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1036 g_free(realwho);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1037 return jbd;
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1038 } else {
5940
94ad4d45346a [gaim-migrate @ 6380]
Nathan Walp <nwalp@pidgin.im>
parents: 5920
diff changeset
1039 g_free(realwho);
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1040 return NULL;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1041 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1042 }
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1043
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
1044 /*
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1045 * find a resource by name, or if no name given, return the "default" resource
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1046 * default being the highest priority one.
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1047 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1048
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1049 static jab_res_info jabber_find_resource(GaimConnection *gc, const char *who)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1050 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1051 GSList *resources;
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1052 struct jabber_buddy_data *jbd = jabber_find_buddy(gc, who, FALSE);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1053 jab_res_info jri = NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1054 char *res = strstr(who, "/");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1055
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1056 if(res)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1057 res++;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1058
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1059 if(jbd)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1060 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1061 resources = jbd->resources;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1062 while(resources)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1063 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1064 if(!jri && !res) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1065 jri = (jab_res_info) resources->data;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1066 } else if(!res) { /* we're looking for the default priority, so... */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1067 if(((jab_res_info) resources->data)->priority >= jri->priority)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1068 jri = (jab_res_info) resources->data;
3337
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1069 } else if(((jab_res_info)resources->data)->name) {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1070 if(!strcasecmp(((jab_res_info) resources->data)->name, res)) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1071 jri = (jab_res_info) resources->data;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1072 break;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1073 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1074 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1075 resources = resources->next;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1076 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1077 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1078
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1079 return jri;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1080 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1081
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
1082 #if 0
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1083 static gboolean jabber_is_default_resource(GaimConnection *gc, const char *who)
5291
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1084 {
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1085 jab_res_info jri = jabber_find_resource(gc, who);
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1086 char *buddy = g_strdup(who);
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1087 char *resource = strrchr(buddy, '/');
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1088
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1089 if(!resource || !strcmp(resource+1, jri->name)) {
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1090 g_free(buddy);
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1091 return TRUE;
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1092 }
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1093
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1094 g_free(buddy);
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1095 return FALSE;
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1096 }
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
1097 #endif
5291
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1098
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1099 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1100 * if the resource doesn't exist, create it. otherwise, just update the priority
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1101 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1102 static void jabber_track_resource(GaimConnection *gc,
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1103 char *buddy,
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1104 char *res,
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1105 int priority,
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1106 int state)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1107 {
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1108 struct jabber_buddy_data *jbd = jabber_find_buddy(gc, buddy, TRUE);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1109
3337
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1110 if(jbd) {
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1111 char *who;
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1112 jab_res_info jri;
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1113 if(res)
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1114 who = g_strdup_printf("%s/%s", buddy, res);
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1115 else
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1116 who = g_strdup(buddy);
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1117 jri = jabber_find_resource(gc, who);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1118 g_free(who);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1119 if(!jri) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1120 jri = g_new0(struct jabber_resource_info, 1);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1121 jri->name = g_strdup(res);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1122 jri->away_msg = NULL;
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1123 jri->has_xhtml = TRUE;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1124 jbd->resources = g_slist_append(jbd->resources, jri);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1125 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1126 jri->priority = priority;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1127 jri->state = state;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1128 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1129 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1130
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1131 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1132 * remove the resource, if it exists
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1133 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1134 static void jabber_remove_resource(GaimConnection *gc, char *buddy, char *res)
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1135 {
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1136 struct jabber_buddy_data *jbd = jabber_find_buddy(gc, buddy, FALSE);
3337
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1137 if(jbd) {
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1138 char *who;
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1139 jab_res_info jri;
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1140 if(res)
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1141 who = g_strdup_printf("%s/%s", buddy, res);
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1142 else
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1143 who = g_strdup(buddy);
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1144 jri = jabber_find_resource(gc, who);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1145 g_free(who);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1146 if(jri) {
3337
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1147 if(jri->name)
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1148 g_free(jri->name);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1149 if(jri->away_msg)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1150 g_free(jri->away_msg);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1151 jbd->resources = g_slist_remove(jbd->resources, jri);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1152 g_free(jri);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1153 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1154 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1155 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1156
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1157 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1158 * grab the away message for the default resource
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1159 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1160 static char *jabber_lookup_away(gjconn gjc, char *name)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1161 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1162 jab_res_info jri = jabber_find_resource(GJ_GC(gjc), name);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1163
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1164 if(!jri)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1165 return _("Unknown");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1166
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1167 return jri->away_msg;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1168 }
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1169 static const char *jabber_get_state_string(int s) {
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1170 switch(s) {
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1171 case UC_AWAY:
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1172 return _("Away");
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1173 case UC_CHAT:
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1174 return _("Chatty");
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1175 case UC_XA:
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1176 return _("Extended Away");
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1177 case UC_DND:
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1178 return _("Do Not Disturb");
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1179 default:
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1180 return _("Available");
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1181 }
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1182 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1183
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1184 static void jabber_track_away(gjconn gjc, jpacket p, char *type)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1185 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1186 jab_res_info jri = NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1187
3337
e77fcff466a1 [gaim-migrate @ 3356]
Jim Seymour <jseymour>
parents: 3328
diff changeset
1188 if(!p || !p->from || !p->from->user)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1189 return;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1190
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1191 jri = jabber_find_resource(GJ_GC(gjc), jid_full(p->from));
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1192
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1193 if(!jri)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1194 return;
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1195
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1196 if(jri->away_msg)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1197 g_free(jri->away_msg);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1198
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1199 jri->away_msg = g_strdup(xmlnode_get_tag_data(p->x, "status"));
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1200 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1201
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1202 static void jabber_convo_closed(GaimConnection *gc, char *name)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1203 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1204 jab_res_info jri = jabber_find_resource(gc, name);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1205
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1206 if(jri) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1207 if(jri->thread_id)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1208 g_free(jri->thread_id);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1209
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1210 jri->thread_id = NULL;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1211 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1212 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1213
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1214 static void jabber_track_convo_thread(gjconn gjc, char *name, char *thread_id)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1215 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1216 jab_res_info jri = jabber_find_resource(GJ_GC(gjc), name);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1217
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1218 if(jri) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1219 if(jri->thread_id)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1220 g_free(jri->thread_id);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1221
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1222 jri->thread_id = g_strdup(thread_id);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1223 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1224 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1225
5136
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
1226 static char *jabber_get_convo_thread(gjconn gjc, const char *name)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1227 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1228 char *ct = NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1229 jab_res_info jri = jabber_find_resource(GJ_GC(gjc), name);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1230
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1231 if(jri) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1232 if(jri->thread_id)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1233 ct = g_strdup(jri->thread_id);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1234 }
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1235
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1236 return ct;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1237 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1238
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1239
5426
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1240 static time_t str_to_time(char *timestamp)
3159
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
1241 {
5426
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1242 struct tm t;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1243 time_t retval = 0;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1244 char buf[32];
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1245 char *c;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1246 int tzoff = 0;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1247
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1248 time(&retval);
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1249 localtime_r(&retval, &t);
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1250
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1251 snprintf(buf, sizeof(buf), "%s", timestamp);
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1252 c = buf;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1253
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1254 /* 4 digit year */
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1255 if(!sscanf(c, "%04d", &t.tm_year)) return 0;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1256 c+=4;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1257 if(*c == '-')
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1258 c++;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1259
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1260 t.tm_year -= 1900;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1261
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1262 /* 2 digit month */
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1263 if(!sscanf(c, "%02d", &t.tm_mon)) return 0;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1264 c+=2;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1265 if(*c == '-')
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1266 c++;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1267
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1268 t.tm_mon -= 1;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1269
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1270 /* 2 digit day */
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1271 if(!sscanf(c, "%02d", &t.tm_mday)) return 0;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1272 c+=2;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1273
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1274 if(*c == 'T') { /* we have more than a date, keep going */
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1275 c++; /* skip the "T" */
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1276
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1277 /* 2 digit hour */
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1278 if(sscanf(c, "%02d:%02d:%02d", &t.tm_hour, &t.tm_min, &t.tm_sec)) {
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1279 int tzhrs, tzmins;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1280 c+=8;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1281 if(*c == '.') /* dealing with precision we don't care about */
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1282 c += 4;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1283
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1284 if((*c == '+' || *c == '-') &&
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1285 sscanf(c+1, "%02d:%02d", &tzhrs, &tzmins)) {
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1286 tzoff = tzhrs*60*60 + tzmins*60;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1287 if(*c == '+')
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1288 tzoff *= -1;
5279
36523a0d8459 [gaim-migrate @ 5651]
Nathan Walp <nwalp@pidgin.im>
parents: 5264
diff changeset
1289 }
5426
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1290
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1291 #ifdef HAVE_TM_GMTOFF
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1292 tzoff += t.tm_gmtoff;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1293 #else
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1294 # ifdef HAVE_TIMEZONE
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1295 tzset(); /* making sure */
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1296 tzoff -= timezone;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1297 # endif
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1298 #endif
5279
36523a0d8459 [gaim-migrate @ 5651]
Nathan Walp <nwalp@pidgin.im>
parents: 5264
diff changeset
1299 }
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1300 }
5426
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1301 retval = mktime(&t);
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1302
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1303 retval += tzoff;
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1304
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1305 return retval;
3159
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
1306 }
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
1307
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1308 static void jabber_handlemessage(gjconn gjc, jpacket p)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1309 {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1310 xmlnode y, subj;
3159
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
1311 time_t time_sent = time(NULL);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1312 gboolean typing = FALSE;
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1313 gboolean has_xhtml = TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1314
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1315 char *from = NULL, *msg = NULL, *type = NULL, *topic = NULL;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1316 char *thread_id = NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1317 char *conference_room = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1318 char m[BUF_LONG * 2];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1319
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1320 type = xmlnode_get_attrib(p->x, "type");
3769
303e40b66b96 [gaim-migrate @ 3908]
Sean Egan <seanegan@gmail.com>
parents: 3768
diff changeset
1321
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1322 if ((y = xmlnode_get_tag(p->x, "thread")))
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1323 thread_id = xmlnode_get_data(y);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1324
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1325 y = xmlnode_get_firstchild(p->x);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1326
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1327 while(y) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1328 if(NSCHECK(y, NS_DELAY)) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1329 char *timestamp = xmlnode_get_attrib(y, "stamp");
5426
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1330 if(timestamp)
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1331 time_sent = str_to_time(timestamp);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1332 } else if(NSCHECK(y, "jabber:x:event")) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1333 if(xmlnode_get_tag(y, "composing"))
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1334 typing = TRUE;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1335 } else if(NSCHECK(y, "jabber:x:conference")) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1336 conference_room = xmlnode_get_attrib(y, "jid");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1337 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1338 y = xmlnode_get_nextsibling(y);
3159
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
1339 }
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
1340
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1341 if (!type || !strcasecmp(type, "normal") || !strcasecmp(type, "chat")) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1342
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1343 from = jid_full(p->from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1344 if ((y = xmlnode_get_tag(p->x, "html"))) {
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1345 msg = xmlnode2str(y);
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1346 } else if ((y = xmlnode_get_tag(p->x, "body"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1347 msg = xmlnode_get_data(y);
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1348 has_xhtml = FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1349 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1350
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1351 if (!from)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1352 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1353
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1354 if (conference_room) {
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1355 GHashTable *components = g_hash_table_new_full(g_str_hash,
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1356 g_str_equal, g_free, g_free);
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1357 char **data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1358
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1359 data = g_strsplit(conference_room, "@", 2);
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1360 g_hash_table_replace(components, g_strdup("room"),
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1361 g_strdup(data[0]));
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1362 g_hash_table_replace(components, g_strdup("server"),
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1363 g_strdup(data[1]));
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1364 g_hash_table_replace(components, g_strdup("handle"),
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1365 g_strdup(gjc->user->user));
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1366 g_strfreev(data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1367
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1368 serv_got_chat_invite(GJ_GC(gjc), conference_room, from, msg, components);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1369 } else if (msg) { /* whisper */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1370 struct jabber_chat *jc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1371 g_snprintf(m, sizeof(m), "%s", msg);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1372 if (((jc = find_existing_chat(GJ_GC(gjc), p->from)) != NULL) && jc->b)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1373 serv_got_chat_in(GJ_GC(gjc),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1374 gaim_chat_get_id(GAIM_CHAT(jc->b)),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1375 p->from->resource, 1, m, time_sent);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1376 else {
2278
00a8b7bcef6c [gaim-migrate @ 2288]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2232
diff changeset
1377 int flags = 0;
3769
303e40b66b96 [gaim-migrate @ 3908]
Sean Egan <seanegan@gmail.com>
parents: 3768
diff changeset
1378 jab_res_info jri = jabber_find_resource(GJ_GC(gjc), from);
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1379 if(jri) {
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1380 if(typing)
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1381 jri->has_composing = TRUE;
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1382 jri->has_xhtml = has_xhtml;
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1383 }
3769
303e40b66b96 [gaim-migrate @ 3908]
Sean Egan <seanegan@gmail.com>
parents: 3768
diff changeset
1384 jabber_track_convo_thread(gjc, from, thread_id);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1385 if (gaim_find_conversation(from))
3769
303e40b66b96 [gaim-migrate @ 3908]
Sean Egan <seanegan@gmail.com>
parents: 3768
diff changeset
1386 serv_got_im(GJ_GC(gjc), from, m, flags,
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1387 time_sent, -1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1388 else {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1389 if(p->from->user) {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1390 from = g_strdup_printf("%s@%s", p->from->user,
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1391 p->from->server);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1392 } else {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1393 /* server message? */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1394 from = g_strdup(p->from->server);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1395 }
3159
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3150
diff changeset
1396 serv_got_im(GJ_GC(gjc), from, m, flags, time_sent, -1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1397 g_free(from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1398 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1399 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1400 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1401 /* a non-message message! */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1402 from = g_strdup_printf("%s@%s", p->from->user, p->from->server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1403 if(typing)
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
1404 serv_got_typing(GJ_GC(gjc), from, 0, GAIM_TYPING);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1405 else
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1406 serv_got_typing_stopped(GJ_GC(gjc), from);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1407 g_free(from);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1408 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1409
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1410 } else if (!strcasecmp(type, "error")) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1411 if ((y = xmlnode_get_tag(p->x, "error"))) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1412 type = xmlnode_get_attrib(y, "code");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 msg = xmlnode_get_data(y);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416 if (msg) {
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3349
diff changeset
1417 from = g_strdup_printf(_("Jabber Error %s"), type ? type : "");
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
1418 gaim_notify_error(GJ_GC(gjc), NULL, from, msg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1419 g_free(from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1420 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421 } else if (!strcasecmp(type, "groupchat")) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1422 struct jabber_chat *jc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1423 static int i = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1425 if ((y = xmlnode_get_tag(p->x, "html"))) {
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1426 msg = xmlnode2str(y);
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
1427 } else if ((y = xmlnode_get_tag(p->x, "body"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1428 msg = xmlnode_get_data(y);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1429 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1430
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1431 if ((subj = xmlnode_get_tag(p->x, "subject"))) {
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1432 topic = xmlnode_get_data(subj);
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1433 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1434
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1435 jc = find_existing_chat(GJ_GC(gjc), p->from);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1436 if (!jc) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1437 /* we're not in this chat. are we supposed to be? */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1438 if ((jc = find_pending_chat(GJ_GC(gjc), p->from)) != NULL) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1439 /* yes, we're supposed to be. so now we are. */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1440 jc->b = serv_got_joined_chat(GJ_GC(gjc), i++, p->from->user);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1441 jc->id = gaim_chat_get_id(GAIM_CHAT(jc->b));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1442 jc->state = JCS_ACTIVE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1443 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1444 /* no, we're not supposed to be. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1445 g_free(msg);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1446 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1447 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1448 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449 if (p->from->resource) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1450 if (!y) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1451 if (!find_chat_buddy(jc->b, p->from->resource)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1452 gaim_chat_add_user(GAIM_CHAT(jc->b),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1453 p->from->resource, NULL);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1454 } else if ((y = xmlnode_get_tag(p->x, "status"))) {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1455 jabber_track_away(gjc, p, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1456 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1457 } else if (jc->b && msg) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1458 char buf[8192];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1459
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1460 if (topic) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1461 char tbuf[8192];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1462 g_snprintf(tbuf, sizeof(tbuf), "%s", topic);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1463 gaim_chat_set_topic(GAIM_CHAT(jc->b),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1464 p->from->resource, tbuf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1465 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1466
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1467 g_snprintf(buf, sizeof(buf), "%s", msg);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1468 serv_got_chat_in(GJ_GC(gjc),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1469 gaim_chat_get_id(GAIM_CHAT(jc->b)),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1470 p->from->resource, 0, buf, time_sent);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1471 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1472 } else { /* message from the server */
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1473 if(jc->b && topic) {
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1474 char tbuf[8192];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1475 g_snprintf(tbuf, sizeof(tbuf), "%s", topic);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1476 gaim_chat_set_topic(GAIM_CHAT(jc->b), "", tbuf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1477 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1478 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1479
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1480 } else {
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1481 gaim_debug(GAIM_DEBUG_WARNING, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1482 "unhandled message %s\n", type);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1483 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1484 }
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1485
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1486 static void jabber_handlepresence(gjconn gjc, jpacket p)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1487 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1488 char *to, *from, *type;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1489 struct buddy *b = NULL;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1490 gaim_jid gjid;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1491 char *buddy;
3194
fdd20785e1e1 [gaim-migrate @ 3211]
Jim Seymour <jseymour>
parents: 3161
diff changeset
1492 xmlnode y;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1493 char *show;
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1494 int state = 0;
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
1495 GaimConversation *cnv = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1496 struct jabber_chat *jc = NULL;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1497 int priority = 0;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1498 struct jabber_buddy_data *jbd;
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1499
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1500 to = xmlnode_get_attrib(p->x, "to");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1501 from = xmlnode_get_attrib(p->x, "from");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1502 type = xmlnode_get_attrib(p->x, "type");
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1503
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1504 if((buddy = get_realwho(gjc, from, FALSE, &gjid)) == NULL)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1505 return;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1506
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1507 if (gjid->user == NULL) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1508 /* FIXME: transport */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1509 g_free(buddy);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1510 gaim_jid_free(gjid);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1511 return;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1512 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1513
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1514 jbd = jabber_find_buddy(GJ_GC(gjc), buddy, TRUE);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1515
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1516 if(jbd->error_msg) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1517 g_free(jbd->error_msg);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1518 jbd->error_msg = NULL;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1519 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1520
3259
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1521 if(type && !strcasecmp(type, "error")) {
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1522 state = UC_ERROR;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1523 if((y = xmlnode_get_tag(p->x, "error")) != NULL) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1524 jbd->error_msg = g_strdup_printf(_("Error %s: %s"),
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1525 xmlnode_get_attrib(y, "code"), xmlnode_get_data(y));
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1526 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1527 jbd->error_msg = g_strdup(_("Unknown Error in presence"));
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1528 }
3259
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1529 } else {
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1530 if ((y = xmlnode_get_tag(p->x, "show"))) {
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1531 show = xmlnode_get_data(y);
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1532 if (!show) {
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1533 state = 0;
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1534 } else if (!strcasecmp(show, "away")) {
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1535 state = UC_AWAY;
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1536 } else if (!strcasecmp(show, "chat")) {
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1537 state = UC_CHAT;
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1538 } else if (!strcasecmp(show, "xa")) {
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1539 state = UC_XA;
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1540 } else if (!strcasecmp(show, "dnd")) {
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1541 state = UC_DND;
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1542 }
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1543 } else {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
1544 state = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1545 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1546 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1547
5291
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1548 if ((y = xmlnode_get_tag(p->x, "priority")))
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1549 priority = atoi(xmlnode_get_data(y));
a6f37a893b49 [gaim-migrate @ 5663]
Nathan Walp <nwalp@pidgin.im>
parents: 5289
diff changeset
1550
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1551 /* um. we're going to check if it's a chat. if it isn't, and there are pending
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1552 * chats, create the chat. if there aren't pending chats and we don't have the
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1553 * buddy on our list, simply bail out. */
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1554 if ((cnv = find_chat(GJ_GC(gjc), gjid->user)) == NULL) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1555 static int i = 0x70;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1556 if ((jc = find_pending_chat(GJ_GC(gjc), gjid)) != NULL) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1557 jc->b = cnv = serv_got_joined_chat(GJ_GC(gjc), i++, gjid->user);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1558 jc->id = gaim_chat_get_id(GAIM_CHAT(jc->b));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1559 jc->state = JCS_ACTIVE;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1560 } else if ((b = gaim_find_buddy(GJ_GC(gjc)->account, buddy)) == NULL) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1561 g_free(buddy);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1562 gaim_jid_free(gjid);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1563 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1564 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1565 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1566
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
1567 if (state == UC_ERROR || (type && (strcasecmp(type, "unavailable") == 0)))
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1568 jabber_remove_resource(GJ_GC(gjc), buddy, gjid->resource);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1569 else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1570 jabber_track_resource(GJ_GC(gjc), buddy, gjid->resource, priority, state);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1571
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1572 /* keep track of away msg somewhat the same as the yahoo plugin */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1573 jabber_track_away(gjc, p, type);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1574 }
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1575
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1576 if (!cnv) {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1577 /* this is where we handle presence information for "regular" buddies */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1578 jab_res_info jri = jabber_find_resource(GJ_GC(gjc), buddy);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1579 if(jri) {
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
1580 serv_got_update(GJ_GC(gjc), buddy, 1, 0, b->signon, b->idle, jri->state);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1581 } else
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
1582 serv_got_update(GJ_GC(gjc), buddy, 0, 0, 0, 0, 0);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1583
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1584 } else {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1585 if (gjid->resource) {
3259
8b1309bea7e5 [gaim-migrate @ 3277]
Jim Seymour <jseymour>
parents: 3257
diff changeset
1586 if (type && (!strcasecmp(type, "unavailable"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1587 struct jabber_data *jd;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1588 if (!jc && !(jc = find_existing_chat(GJ_GC(gjc), gjid))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1589 g_free(buddy);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1590 gaim_jid_free(gjid);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1591 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1592 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1593 jd = jc->gc->proto_data;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1594 /* if it's not ourselves...*/
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1595 if (strcmp(gjid->resource, jc->gjid->resource) && jc->b) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1596 gaim_chat_remove_user(GAIM_CHAT(jc->b), gjid->resource,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1597 NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1598 g_free(buddy);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1599 gaim_jid_free(gjid);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1600 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1601 }
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1602
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1603 jc->state = JCS_CLOSED;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1604 serv_got_chat_left(GJ_GC(gjc), jc->id);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1605 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1606 * TBD: put back some day?
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1607 jd->chats = g_slist_remove(jd->chats, jc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1608 g_free(jc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1609 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1610 } else {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1611 if ((!jc && !(jc = find_existing_chat(GJ_GC(gjc), gjid))) || !jc->b) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1612 g_free(buddy);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1613 gaim_jid_free(gjid);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1614 return;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1615 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1616 if (!find_chat_buddy(jc->b, gjid->resource)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4357
diff changeset
1617 gaim_chat_add_user(GAIM_CHAT(jc->b), gjid->resource, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1618 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1619 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1620 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1621 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1622
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1623 g_free(buddy);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1624 gaim_jid_free(gjid);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1625
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1626 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1627 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1628
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1629 /*
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1630 * Used only by Jabber accept/deny add stuff just below
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1631 */
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1632 struct jabber_add_permit {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1633 GaimConnection *gc;
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1634 gchar *user;
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1635 };
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1636
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1637 /*
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1638 * Common part for Jabber accept/deny adds
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1639 *
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1640 * "type" says whether we'll permit/deny the subscribe request
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1641 */
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1642 static void jabber_accept_deny_add(struct jabber_add_permit *jap, const char *type)
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1643 {
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1644 xmlnode g = xmlnode_new_tag("presence");
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1645
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1646 xmlnode_put_attrib(g, "to", jap->user);
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1647 xmlnode_put_attrib(g, "type", type);
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1648 gjab_send(GC_GJ(jap->gc), g);
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1649
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1650 xmlnode_free(g);
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1651 }
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1652
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1653 /*
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1654 * Callback from "accept" in gaim_request_action() invoked
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1655 * by jabber_handles10n()
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1656 */
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1657 static void jabber_accept_add(struct jabber_add_permit *jap)
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1658 {
5578
847ad796326d [gaim-migrate @ 5982]
Christian Hammond <chipx86@chipx86.com>
parents: 5572
diff changeset
1659 if(g_list_find(gaim_connections_get_all(), jap->gc)) {
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1660 jabber_accept_deny_add(jap, "subscribed");
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1661 /*
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1662 * If we don't already have the buddy on *our* buddylist,
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1663 * ask if we want him or her added.
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1664 */
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1665 if(gaim_find_buddy(jap->gc->account, jap->user) == NULL) {
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1666 show_got_added(jap->gc, NULL, jap->user, NULL, NULL);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1667 }
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1668 }
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1669
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1670 g_free(jap->user);
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1671 g_free(jap);
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1672 }
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1673
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1674 /*
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1675 * Callback from "deny/cancel" in gaim_request_action() invoked
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1676 * by jabber_handles10n()
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1677 */
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3717
diff changeset
1678 static void jabber_deny_add(struct jabber_add_permit *jap)
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1679 {
5578
847ad796326d [gaim-migrate @ 5982]
Christian Hammond <chipx86@chipx86.com>
parents: 5572
diff changeset
1680 if(g_list_find(gaim_connections_get_all(), jap->gc)) {
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1681 jabber_accept_deny_add(jap, "unsubscribed");
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1682 }
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1683
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1684 g_free(jap->user);
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1685 g_free(jap);
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1686 }
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1687
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1688 /*
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1689 * Handle subscription requests
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1690 */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1691 static void jabber_handles10n(gjconn gjc, jpacket p)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1692 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1693 xmlnode g;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1694 char *Jid = xmlnode_get_attrib(p->x, "from");
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1695 char *type = xmlnode_get_attrib(p->x, "type");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1696
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1697 g = xmlnode_new_tag("presence");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1698 xmlnode_put_attrib(g, "to", Jid);
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1699
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1700 if (!strcmp(type, "subscribe")) {
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1701 /*
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1702 * A "subscribe to us" request was received - put up the approval dialog
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1703 */
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1704 struct jabber_add_permit *jap = g_new0(struct jabber_add_permit, 1);
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1705 gchar *msg = g_strdup_printf(_("The user %s wants to add you to their buddy list."),
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1706 Jid);
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1707
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1708 jap->gc = GJ_GC(gjc);
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1709 jap->user = g_strdup(Jid);
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1710
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1711 gaim_request_action(jap->gc, NULL, msg, NULL, 0, jap, 2,
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1712 _("Authorize"), G_CALLBACK(jabber_accept_add),
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1713 _("Deny"), G_CALLBACK(jabber_deny_add));
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1714
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1715 g_free(msg);
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1716 xmlnode_free(g); /* Never needed it here anyway */
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1717 return;
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1718
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1719 } else if (!strcmp(type, "unsubscribe")) {
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1720 /*
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1721 * An "unsubscribe to us" was received - simply "approve" it
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1722 */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723 xmlnode_put_attrib(g, "type", "unsubscribed");
3229
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1724 } else {
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1725 /*
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1726 * Did we attempt to subscribe to somebody and they do not exist?
20612da83d8c [gaim-migrate @ 3246]
Jim Seymour <jseymour>
parents: 3203
diff changeset
1727 */
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1728 if (!strcmp(type, "unsubscribed")) {
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1729 xmlnode y;
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1730 char *status;
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1731 if((y = xmlnode_get_tag(p->x, "status")) && (status = xmlnode_get_data(y)) &&
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1732 !strcmp(status, "Not Found")) {
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3349
diff changeset
1733 char *msg = g_strdup_printf(_("The Jabber user %s does not exist and was therefore "
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3349
diff changeset
1734 "not added to your roster."),
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3349
diff changeset
1735 xmlnode_get_attrib(p->x, "from"));
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
1736 gaim_notify_error(GJ_GC(gjc), NULL, _("No such user."), msg);
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1737 g_free(msg);
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1738 }
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1739 }
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1740
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1741 xmlnode_free(g);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1742 return;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1743 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1744
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1745 gjab_send(gjc, g);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1746 xmlnode_free(g);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1747 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1748
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1749 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1750 * Pending subscription to a buddy?
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1751 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1752 #define BUD_SUB_TO_PEND(sub, ask) ((!strcasecmp((sub), "none") || !strcasecmp((sub), "from")) && \
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1753 (ask) != NULL && !strcasecmp((ask), "subscribe"))
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1754
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1755 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1756 * Subscribed to a buddy?
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1757 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1758 #define BUD_SUBD_TO(sub, ask) ((!strcasecmp((sub), "to") || !strcasecmp((sub), "both")) && \
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1759 ((ask) == NULL || !strcasecmp((ask), "subscribe")))
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1760
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1761 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1762 * Pending unsubscription to a buddy?
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1763 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1764 #define BUD_USUB_TO_PEND(sub, ask) ((!strcasecmp((sub), "to") || !strcasecmp((sub), "both")) && \
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1765 (ask) != NULL && !strcasecmp((ask), "unsubscribe"))
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1766
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1767 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1768 * Unsubscribed to a buddy?
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1769 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1770 #define BUD_USUBD_TO(sub, ask) ((!strcasecmp((sub), "none") || !strcasecmp((sub), "from")) && \
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1771 ((ask) == NULL || !strcasecmp((ask), "unsubscribe")))
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1772
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1773 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1774 * If a buddy is added or removed from the roster on another resource
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1775 * jabber_handlebuddy is called
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1776 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1777 * Called with roster item node.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1778 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1779 static void jabber_handlebuddy(gjconn gjc, xmlnode x)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1780 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1781 xmlnode g;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1782 char *who, *name, *sub, *ask;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1783 gaim_jid gjid;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1784 struct buddy *b = NULL;
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1785 struct jabber_buddy_data *jbd = NULL;
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1786 char *buddyname, *groupname = NULL;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1787
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1788 who = xmlnode_get_attrib(x, "jid");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1789 name = xmlnode_get_attrib(x, "name");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1790 sub = xmlnode_get_attrib(x, "subscription");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1791 ask = xmlnode_get_attrib(x, "ask");
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1792
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1793 if((buddyname = get_realwho(gjc, who, FALSE, &gjid)) == NULL)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1794 return;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1795
4705
e34fe984f999 [gaim-migrate @ 5016]
Nathan Walp <nwalp@pidgin.im>
parents: 4690
diff changeset
1796
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1797 /* JFIXME: jabber_handleroster() had a "FIXME: transport" at this
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1798 * equivilent point. So...
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1799 *
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1800 * We haven't done anything interesting to this point, so we'll
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1801 * violate Good Coding Structure here by simply bailing out.
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1802 */
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1803 if(!gjid->user) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1804 g_free(buddyname);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1805 gaim_jid_free(gjid);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1806 return;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1807 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
1808 gaim_jid_free(gjid);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1809
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
1810 if((g = xmlnode_get_tag(x, "group")) != NULL) {
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1811 groupname = xmlnode_get_data(g);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1812 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1813
3059
966c4e460ebb [gaim-migrate @ 3073]
Sean Egan <seanegan@gmail.com>
parents: 3048
diff changeset
1814 /*
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1815 * Add or remove a buddy? Change buddy's alias or group?
3059
966c4e460ebb [gaim-migrate @ 3073]
Sean Egan <seanegan@gmail.com>
parents: 3048
diff changeset
1816 */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1817 if (BUD_SUB_TO_PEND(sub, ask) || BUD_SUBD_TO(sub, ask)) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1818 if ((b = gaim_find_buddy(GJ_GC(gjc)->account, buddyname)) == NULL) {
4932
af89e6b99c1a [gaim-migrate @ 5266]
Nathan Walp <nwalp@pidgin.im>
parents: 4927
diff changeset
1819 struct group *g;
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1820 b = gaim_buddy_new(GJ_GC(gjc)->account, buddyname, name);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1821 if (groupname) {
4775
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
1822 if (!(g = gaim_find_group(groupname))) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1823 g = gaim_group_new(groupname);
4775
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
1824 gaim_blist_add_group(g, NULL);
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
1825 }
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
1826 } else {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1827 g = gaim_group_new(_("Buddies"));
4775
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
1828 gaim_blist_add_group(g, NULL);
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
1829 }
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1830 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1831 "adding buddy [4]: %s\n", buddyname);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1832 gaim_blist_add_buddy(b, g, NULL);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4333
diff changeset
1833 gaim_blist_save();
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1834 } else {
5264
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1835 gboolean save = FALSE;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1836 struct group *c_grp = gaim_find_buddys_group(b);
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1837
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1838 /*
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1839 * If the buddy's in a new group or his/her alias is changed...
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1840 */
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
1841 if(groupname && c_grp && strcmp(c_grp->name, groupname)) {
5264
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1842 struct group *g = gaim_find_group(groupname);
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1843 if(!g) {
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1844 g = gaim_group_new(groupname);
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1845 gaim_blist_add_group(g, NULL);
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1846 }
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1847
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1848 gaim_blist_add_buddy(b, g, NULL);
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1849 save = TRUE;
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1850 }
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1851
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1852 if(name && (!b->alias || strcmp(b->alias, name))) {
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1853 gaim_blist_alias_buddy(b, name);
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1854 save = TRUE;
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1855 }
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1856
e4dadc60ea5a [gaim-migrate @ 5636]
Nathan Walp <nwalp@pidgin.im>
parents: 5236
diff changeset
1857 if(save)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4333
diff changeset
1858 gaim_blist_save();
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1859 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1860 } else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) {
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
1861 jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1862 }
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1863 if(b && (jbd = jabber_find_buddy(b->account->gc, buddyname, TRUE)) != NULL) {
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1864 jbd->subscription = JABBER_SUB_NONE;
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1865 if(!strcasecmp(sub, "to"))
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1866 jbd->subscription |= JABBER_SUB_TO;
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1867 else if(!strcasecmp(sub, "from"))
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1868 jbd->subscription |= JABBER_SUB_FROM;
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1869 else if(!strcasecmp(sub, "both"))
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1870 jbd->subscription |= JABBER_SUB_BOTH;
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1871
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1872 if(ask && !strcasecmp(ask, "subscribe"))
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1873 jbd->subscription |= JABBER_SUB_PENDING;
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1874 }
3328
d183c2703508 [gaim-migrate @ 3346]
Jim Seymour <jseymour>
parents: 3314
diff changeset
1875
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1876 g_free(buddyname);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1877
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1878 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1879
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1880 static void jabber_handleroster(gjconn gjc, xmlnode querynode)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1881 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1882 xmlnode x;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1883
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1884 x = xmlnode_get_firstchild(querynode);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1885 while (x) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1886 jabber_handlebuddy(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1887 x = xmlnode_get_nextsibling(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1888 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1889
5426
8d8bf0d31a23 [gaim-migrate @ 5805]
Nathan Walp <nwalp@pidgin.im>
parents: 5393
diff changeset
1890 x = xmlnode_new_tag("presence");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1891 gjab_send(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1892 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1893 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1894
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1895 static void jabber_handleauthresp(gjconn gjc, jpacket p)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1896 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1897 if (jpacket_subtype(p) == JPACKET__RESULT) {
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
1898 if (xmlnode_has_children(p->x)) {
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
1899 xmlnode query = xmlnode_get_tag(p->x, "query");
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1900 gaim_connection_update_progress(GJ_GC(gjc), _("Authenticating"),
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1901 4, JABBER_CONNECT_STEPS);
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
1902 if (!xmlnode_get_tag(query, "digest")) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1903 g_free(gjc->sid);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1904 gjc->sid = NULL;
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
1905 }
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1906 gjab_auth(gjc);
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
1907 } else {
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1908 gaim_debug(GAIM_DEBUG_INFO, "jabber", "auth success\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1909
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1910 gaim_connection_set_state(GJ_GC(gjc), GAIM_CONNECTED);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1911 serv_finish_login(GJ_GC(gjc));
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1912
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1913 ((struct jabber_data *)GJ_GC(gjc)->proto_data)->did_import = TRUE;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1914
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1915 gjab_reqroster(gjc);
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
1916 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1917 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1918 xmlnode xerr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1919 char *errmsg = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1920 int errcode = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1921
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
1922 gaim_debug(GAIM_DEBUG_ERROR, "jabber", "auth failed\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1923 xerr = xmlnode_get_tag(p->x, "error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1924 if (xerr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1925 char msg[BUF_LONG];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1926 errmsg = xmlnode_get_data(xerr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1927 if (xmlnode_get_attrib(xerr, "code")) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1928 errcode = atoi(xmlnode_get_attrib(xerr, "code"));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1929 g_snprintf(msg, sizeof(msg), "Error %d: %s", errcode, errmsg);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1930 } else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1931 g_snprintf(msg, sizeof(msg), "%s", errmsg);
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1932 gaim_connection_error(GJ_GC(gjc), msg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1933 } else {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
1934 gaim_connection_error(GJ_GC(gjc), _("Unknown login error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1935 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1936 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1937 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1938
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1939 static void jabber_handleversion(gjconn gjc, xmlnode iqnode) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1940 xmlnode querynode, x;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1941 char *id, *from;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1942 char os[1024];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1943 struct utsname osinfo;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1944
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1945 uname(&osinfo);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1946 g_snprintf(os, sizeof os, "%s %s %s", osinfo.sysname, osinfo.release, osinfo.machine);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1947
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1948 id = xmlnode_get_attrib(iqnode, "id");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1949 from = xmlnode_get_attrib(iqnode, "from");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1950
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1951 x = jutil_iqnew(JPACKET__RESULT, NS_VERSION);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1952
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1953 xmlnode_put_attrib(x, "to", from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1954 xmlnode_put_attrib(x, "id", id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1955 querynode = xmlnode_get_tag(x, "query");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1956 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "name"), PACKAGE, -1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1957 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "version"), VERSION, -1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1958 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "os"), os, -1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1959
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1960 gjab_send(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1961
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1962 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1963 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1964
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1965 static void jabber_handletime(gjconn gjc, xmlnode iqnode) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1966 xmlnode querynode, x;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1967 char *id, *from;
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1968 time_t now_t;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1969 struct tm *now;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1970 char buf[1024];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1971
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1972 time(&now_t);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1973 now = localtime(&now_t);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1974
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1975 id = xmlnode_get_attrib(iqnode, "id");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1976 from = xmlnode_get_attrib(iqnode, "from");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1977
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1978 x = jutil_iqnew(JPACKET__RESULT, NS_TIME);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1979
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1980 xmlnode_put_attrib(x, "to", from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1981 xmlnode_put_attrib(x, "id", id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1982 querynode = xmlnode_get_tag(x, "query");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1983
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1984 strftime(buf, 1024, "%Y%m%dT%T", now);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1985 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "utc"), buf, -1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1986 strftime(buf, 1024, "%Z", now);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1987 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "tz"), buf, -1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1988 strftime(buf, 1024, "%d %b %Y %T", now);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1989 xmlnode_insert_cdata(xmlnode_insert_tag(querynode, "display"), buf, -1);
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
1990
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1991 gjab_send(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1992
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1993 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1994 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1995
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
1996 struct jabber_xfer_data {
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
1997 struct g_url *url;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
1998 GString *headers;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
1999 gboolean newline;
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2000
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2001 char *iq_id;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2002
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2003 struct jabber_data *jd;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2004 };
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2005
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2006 static void jabber_xfer_init(struct gaim_xfer *xfer)
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2007 {
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2008 struct jabber_xfer_data *data = xfer->data;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2009 gaim_xfer_start(xfer, -1, data->url->address, data->url->port);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2010 }
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2011
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2012 static void jabber_xfer_free(struct gaim_xfer *xfer)
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2013 {
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2014 struct jabber_xfer_data *data = xfer->data;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2015 data->jd->file_transfers = g_slist_remove(data->jd->file_transfers, xfer);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2016
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2017 g_string_free(data->headers, TRUE);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2018 g_free(data->url);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2019 g_free(data->iq_id);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2020 g_free(data);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2021
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2022 xfer->data = NULL;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2023 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2024
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2025 static void jabber_xfer_end(struct gaim_xfer *xfer)
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2026 {
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2027 struct jabber_xfer_data *data = xfer->data;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2028 xmlnode x;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2029
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2030 x = xmlnode_new_tag("iq");
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2031 xmlnode_put_attrib(x, "type", "result");
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2032 xmlnode_put_attrib(x, "to", xfer->who);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2033 xmlnode_put_attrib(x, "id", data->iq_id);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2034
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2035 gjab_send(data->jd->gjc, x);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2036
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2037 xmlnode_free(x);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2038
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2039 jabber_xfer_free(xfer);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2040 }
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2041
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2042 static void jabber_xfer_start(struct gaim_xfer *xfer)
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2043 {
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2044 struct jabber_xfer_data *data = xfer->data;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2045 char *buf = g_strdup_printf("GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n",
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2046 data->url->page, data->url->address);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2047 write(xfer->fd, buf, strlen(buf));
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2048 g_free(buf);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2049 }
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2050
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2051 static size_t jabber_xfer_read(char **buffer, struct gaim_xfer *xfer) {
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2052 struct jabber_xfer_data *data = xfer->data;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2053 char test;
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5432
diff changeset
2054 int size;
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2055
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2056 if(read(xfer->fd, &test, sizeof(test)) > 0) {
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2057 data->headers = g_string_append_c(data->headers, test);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2058 if(test == '\r')
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2059 return 0;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2060 if(test == '\n') {
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2061 if(data->newline) {
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2062 gchar *lenstr = strstr(data->headers->str, "Content-Length: ");
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2063 if(lenstr) {
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5432
diff changeset
2064 sscanf(lenstr, "Content-Length: %d", &size);
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2065 gaim_xfer_set_size(xfer, size);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2066 }
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2067 gaim_xfer_set_read_fnc(xfer, NULL);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2068 return 0;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2069 } else
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2070 data->newline = TRUE;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2071 return 0;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2072 }
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2073 data->newline = FALSE;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2074 return 0;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2075 }
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2076 return 0;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2077 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2078
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
2079 static void jabber_xfer_cancel_send(struct gaim_xfer *xfer) {
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
2080 }
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
2081
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
2082 static void jabber_xfer_cancel_recv(struct gaim_xfer *xfer) {
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2083 struct jabber_xfer_data *data = xfer->data;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2084 xmlnode x,y;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2085
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2086 x = xmlnode_new_tag("iq");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2087 xmlnode_put_attrib(x, "type", "error");
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2088 xmlnode_put_attrib(x, "to", xfer->who);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2089 xmlnode_put_attrib(x, "id", data->iq_id);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2090 y = xmlnode_insert_tag(x, "error");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2091 /* FIXME: need to handle other kinds of errors here */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2092 xmlnode_put_attrib(y, "code", "406");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2093 xmlnode_insert_cdata(y, "File Transfer Refused", -1);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2094
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2095 gjab_send(data->jd->gjc, x);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2096
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2097 xmlnode_free(x);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2098
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2099 jabber_xfer_free(xfer);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2100 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2101
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2102 static void jabber_handleoob(gjconn gjc, xmlnode iqnode) {
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2103 struct jabber_xfer_data *xfer_data;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2104 struct jabber_data *jd = GJ_GC(gjc)->proto_data;
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
2105 struct gaim_xfer *xfer;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2106 char *msg = NULL;
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2107 char *filename;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2108 xmlnode querynode = xmlnode_get_tag(iqnode, "query");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2109 xmlnode urlnode,descnode;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2110
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2111 if(!querynode)
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2112 return;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2113 urlnode = xmlnode_get_tag(querynode, "url");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2114 if(!urlnode)
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2115 return;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2116 descnode = xmlnode_get_tag(querynode, "desc");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2117 if(descnode)
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2118 msg = xmlnode_get_data(descnode);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2119
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2120 xfer_data = g_new0(struct jabber_xfer_data, 1);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2121 xfer_data->url = parse_url(xmlnode_get_data(urlnode));
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2122 xfer_data->jd = jd;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2123 xfer_data->headers = g_string_new("");
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2124 xfer_data->iq_id = g_strdup(xmlnode_get_attrib(iqnode, "id"));
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2125
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2126 xfer = gaim_xfer_new(GJ_GC(gjc)->account, GAIM_XFER_RECEIVE,
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2127 xmlnode_get_attrib(iqnode, "from"));
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2128 xfer->data = xfer_data;
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2129
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2130 filename = g_strdup(g_strrstr(xfer_data->url->page, "/"));
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2131 if(!filename)
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2132 filename = g_strdup(xfer_data->url->page);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2133
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2134 gaim_xfer_set_filename(xfer, filename);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2135
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2136 g_free(filename);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2137
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2138 gaim_xfer_set_init_fnc(xfer, jabber_xfer_init);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2139 gaim_xfer_set_end_fnc(xfer, jabber_xfer_end);
4675
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
2140 gaim_xfer_set_cancel_send_fnc(xfer, jabber_xfer_cancel_send);
3145c5c45877 [gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents: 4634
diff changeset
2141 gaim_xfer_set_cancel_recv_fnc(xfer, jabber_xfer_cancel_recv);
4538
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2142 gaim_xfer_set_read_fnc(xfer, jabber_xfer_read);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2143 gaim_xfer_set_start_fnc(xfer, jabber_xfer_start);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2144
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2145 jd->file_transfers = g_slist_append(jd->file_transfers, xfer);
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2146
009e206f260c [gaim-migrate @ 4817]
Nathan Walp <nwalp@pidgin.im>
parents: 4508
diff changeset
2147 gaim_xfer_request(xfer);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2148 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2149
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2150 static void jabber_handlelast(gjconn gjc, xmlnode iqnode) {
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2151 xmlnode x, querytag;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2152 char *id, *from;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2153 struct jabber_data *jd = GJ_GC(gjc)->proto_data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2154 char idle_time[32];
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2155
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2156 id = xmlnode_get_attrib(iqnode, "id");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2157 from = xmlnode_get_attrib(iqnode, "from");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2158
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2159 x = jutil_iqnew(JPACKET__RESULT, "jabber:iq:last");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2160
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2161 xmlnode_put_attrib(x, "to", from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2162 xmlnode_put_attrib(x, "id", id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2163 querytag = xmlnode_get_tag(x, "query");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2164 g_snprintf(idle_time, sizeof idle_time, "%ld", jd->idle ? time(NULL) - jd->idle : 0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2165 xmlnode_put_attrib(querytag, "seconds", idle_time);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2166
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2167 gjab_send(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2168 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2169 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2170
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2171 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2172 * delete == TRUE: delete found entry
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2173 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2174 * returns pointer to (local) copy of value if found, NULL otherwise
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2175 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2176 * Note: non-reentrant! Local static storage re-used on subsequent calls.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2177 * If you're going to need to keep the returned value, make a copy!
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2178 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2179 static gchar *jabber_track_queries(GHashTable *queries, gchar *key, gboolean delete)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2180 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2181 gpointer my_key, my_val;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2182 static gchar *ret_val = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2183
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2184 if(ret_val != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2185 g_free(ret_val);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2186 ret_val = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2187 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2188
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2189 /* self-protection */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2190 if(queries != NULL && key != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2191 if(g_hash_table_lookup_extended(queries, key, &my_key, &my_val)) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2192 ret_val = g_strdup((gchar *) my_val);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2193 if(delete) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2194 g_hash_table_remove(queries, key);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2195 g_free(my_key);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2196 g_free(my_val);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2197 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2198 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2199 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2200
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2201 return(ret_val);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2202 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2203
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2204 static void jabber_handlepacket(gjconn gjc, jpacket p)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2205 {
5994
b4a3628b7af2 [gaim-migrate @ 6442]
Nathan Walp <nwalp@pidgin.im>
parents: 5957
diff changeset
2206 char *id, *from, *to;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2207 switch (p->type) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2208 case JPACKET_MESSAGE:
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2209 jabber_handlemessage(gjc, p);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2210 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2211 case JPACKET_PRESENCE:
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2212 jabber_handlepresence(gjc, p);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2213 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2214 case JPACKET_IQ:
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2215 gaim_debug(GAIM_DEBUG_MISC, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2216 "jpacket_subtype: %d\n", jpacket_subtype(p));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2217
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2218 id = xmlnode_get_attrib(p->x, "id");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2219 if (id != NULL && !strcmp(id, IQID_AUTH)) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2220 jabber_handleauthresp(gjc, p);
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
2221 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2222 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2223
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2224 if (jpacket_subtype(p) == JPACKET__SET) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2225 xmlnode querynode;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2226 querynode = xmlnode_get_tag(p->x, "query");
5994
b4a3628b7af2 [gaim-migrate @ 6442]
Nathan Walp <nwalp@pidgin.im>
parents: 5957
diff changeset
2227 from = xmlnode_get_attrib(p->x, "from");
b4a3628b7af2 [gaim-migrate @ 6442]
Nathan Walp <nwalp@pidgin.im>
parents: 5957
diff changeset
2228 to = xmlnode_get_attrib(p->x, "to");
6004
3b4f94adc7d4 [gaim-migrate @ 6452]
Nathan Walp <nwalp@pidgin.im>
parents: 6003
diff changeset
2229 if (NSCHECK(querynode, "jabber:iq:roster") && (!from || !strcmp(from, to))) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2230 jabber_handlebuddy(gjc, xmlnode_get_firstchild(querynode));
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2231 } else if(NSCHECK(querynode, "jabber:iq:oob")) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3613
diff changeset
2232 jabber_handleoob(gjc, p->x);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2233 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2234 } else if (jpacket_subtype(p) == JPACKET__GET) {
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
2235 xmlnode querynode;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2236 querynode = xmlnode_get_tag(p->x, "query");
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
2237 if (NSCHECK(querynode, NS_VERSION)) {
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
2238 jabber_handleversion(gjc, p->x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2239 } else if (NSCHECK(querynode, NS_TIME)) {
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
2240 jabber_handletime(gjc, p->x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2241 } else if (NSCHECK(querynode, "jabber:iq:last")) {
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
2242 jabber_handlelast(gjc, p->x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2243 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2244 } else if (jpacket_subtype(p) == JPACKET__RESULT) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2245 xmlnode querynode, vcard;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2246 char *xmlns, *from;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2247
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2248 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2249 * TBD: ISTM maybe this part could use a serious re-work?
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2250 */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2251 from = xmlnode_get_attrib(p->x, "from");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2252 querynode = xmlnode_get_tag(p->x, "query");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2253 vcard = xmlnode_get_tag(p->x, "vCard");
2316
ebb5ecb2cd5b [gaim-migrate @ 2326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2309
diff changeset
2254 if (!vcard)
ebb5ecb2cd5b [gaim-migrate @ 2326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2309
diff changeset
2255 vcard = xmlnode_get_tag(p->x, "VCARD");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2256
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2257 if (NSCHECK(querynode, NS_ROSTER)) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2258 jabber_handleroster(gjc, querynode);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2259 } else if (NSCHECK(querynode, NS_VCARD)) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2260 jabber_track_queries(gjc->queries, id, TRUE); /* delete query track */
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
2261 jabber_handlevcard(gjc, querynode, from);
2316
ebb5ecb2cd5b [gaim-migrate @ 2326]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2309
diff changeset
2262 } else if (vcard) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2263 jabber_track_queries(gjc->queries, id, TRUE); /* delete query track */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2264 jabber_handlevcard(gjc, vcard, from);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2265 } else if((xmlns = xmlnode_get_attrib(querynode, "xmlns")) != NULL) {
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2266 gaim_debug(GAIM_DEBUG_MISC, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2267 "jabber:iq:query: %s\n", xmlns);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2268 } else {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2269 char *val;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2270
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2271 gaim_debug(GAIM_DEBUG_MISC, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2272 "jabber:iq: %s\n", xmlnode2str(p->x));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2273
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2274 /* handle "null" query results */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2275 if((val = jabber_track_queries(gjc->queries, id, TRUE)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2276 if(strcmp((char *) val, "vCard") == 0) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2277 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2278 * No actual vCard, but there's other stuff. This
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2279 * way the user always gets some kind of response.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2280 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2281 jabber_handlevcard(gjc, NULL, from);
3257
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
2282 } else if(!strcmp((char *) val, "change_password")) {
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
2283 char buf[BUF_LONG];
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2284 sprintf(buf, _("Password successfully changed."));
3257
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
2285
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
2286 gaim_notify_info(GJ_GC(gjc), NULL, buf, NULL);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2287 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2288 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2289 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2290
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2291 } else if (jpacket_subtype(p) == JPACKET__ERROR) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2292 xmlnode xerr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2293 char *from, *errmsg = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294 int errcode = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2295
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2296 from = xmlnode_get_attrib(p->x, "from");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2297 xerr = xmlnode_get_tag(p->x, "error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2298 if (xerr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2299 errmsg = xmlnode_get_data(xerr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2300 if (xmlnode_get_attrib(xerr, "code"))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2301 errcode = atoi(xmlnode_get_attrib(xerr, "code"));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2302 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2303
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3349
diff changeset
2304 from = g_strdup_printf("Jabber Error %d (%s)", errcode, from);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
2305 gaim_notify_error(GJ_GC(gjc), NULL, from, errmsg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2306 g_free(from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2307
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2308 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2309
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2310 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2311 case JPACKET_S10N:
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2312 jabber_handles10n(gjc, p);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2313 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2314 default:
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2315 gaim_debug(GAIM_DEBUG_MISC, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2316 "jabber: packet type %d (%s)\n", p->type, xmlnode2str(p->x));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2317 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2318
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2319 xmlnode_free(p->x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2320
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2321 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2322 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2323
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2324 static void jabber_handlestate(gjconn gjc, int state)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2325 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2326 switch (state) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2327 case JCONN_STATE_OFF:
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
2328 if(gjc->was_connected) {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2329 gaim_connection_error(GJ_GC(gjc), _("Connection lost"));
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
2330 } else {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2331 gaim_connection_error(GJ_GC(gjc), _("Unable to connect"));
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
2332 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2333 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2334 case JCONN_STATE_CONNECTED:
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
2335 gjc->was_connected = 1;
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2336 gaim_connection_update_progress(GJ_GC(gjc), _("Connected"), 2, JABBER_CONNECT_STEPS);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2337 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2338 case JCONN_STATE_ON:
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2339 gaim_connection_update_progress(GJ_GC(gjc), _("Requesting Authentication Method"), 3, JABBER_CONNECT_STEPS);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2340 gjab_reqauth(gjc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2341 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2342 default:
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2343 gaim_debug(GAIM_DEBUG_MISC, "jabber", "state change: %d\n", state);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2344 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2345 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2346 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2347
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2348 static void jabber_login(GaimAccount *account)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2349 {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2350 GaimConnection *gc = gaim_account_get_connection(account);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2351 struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1);
4917
c0c6efda8151 [gaim-migrate @ 5251]
Sean Egan <seanegan@gmail.com>
parents: 4916
diff changeset
2352 char *loginname = create_valid_jid(account->username, DEFAULT_SERVER, "Gaim");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2353
5174
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
2354 gc->flags |= OPT_CONN_HTML;
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
2355
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2356 jd->buddies = g_hash_table_new(g_str_hash, g_str_equal);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2357 jd->chats = NULL; /* we have no chats yet */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2358
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2359 gaim_connection_update_progress(gc, _("Connecting"), 1, JABBER_CONNECT_STEPS);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2360
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4452
diff changeset
2361 if (!(jd->gjc = gjab_new(loginname, account->password, gc))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2362 g_free(loginname);
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2363 gaim_debug(GAIM_DEBUG_ERROR, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2364 "unable to connect (jab_new failed)\n");
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2365 gaim_connection_error(gc, _("Unable to connect"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2366 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2367 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2368
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2369 g_free(loginname);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2370 gjab_state_handler(jd->gjc, jabber_handlestate);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2371 gjab_packet_handler(jd->gjc, jabber_handlepacket);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2372 jd->gjc->queries = g_hash_table_new(g_str_hash, g_str_equal);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2373 gjab_start(jd->gjc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2374 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2375
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2376 static gboolean jabber_destroy_hash(gpointer key, gpointer val, gpointer data) {
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
2377 g_free(key);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2378 g_free(val);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2379 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2380 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2381
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2382 static gboolean jabber_destroy_buddy_hash(gpointer key, gpointer val, gpointer data) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2383 struct jabber_buddy_data *jbd = val;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2384 while (jbd->resources) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2385 g_free(((jab_res_info) ((GSList *)jbd->resources)->data)->name);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2386 if(((jab_res_info) ((GSList *)jbd->resources)->data)->away_msg)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2387 g_free(((jab_res_info) ((GSList *)jbd->resources)->data)->away_msg);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2388 g_free(((GSList *)jbd->resources)->data);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2389 jbd->resources = g_slist_remove(jbd->resources, ((GSList *)jbd->resources)->data);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2390
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2391 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2392 if(jbd->error_msg)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2393 g_free(jbd->error_msg);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2394 g_free(key);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2395 g_free(jbd);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2396 return TRUE;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2397 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2398
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2399
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2400 static gboolean jabber_free(gpointer data)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2401 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2402 struct jabber_data *jd = data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2403
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2404 if(jd->gjc != NULL) {
3486
8e688863a9f1 [gaim-migrate @ 3542]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
2405 g_free(jd->gjc->sid);
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2406 gjab_delete(jd->gjc);
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2407 jd->gjc = NULL;
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2408 }
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2409 g_free(jd);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2410
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2411 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2412 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2413
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2414 static void jabber_close(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2415 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2416 struct jabber_data *jd = gc->proto_data;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2417
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2418 if(jd) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2419 GSList *jcs = jd->chats;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2420
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2421 /* Free-up the jabber_chat struct allocs and the list */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2422 while (jcs) {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2423 gaim_jid_free(((struct jabber_chat *)jcs->data)->gjid);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2424 g_free(jcs->data);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2425 jcs = jcs->next;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2426 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2427 g_slist_free(jd->chats);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2428
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2429 /* Free-up the buddy data hash */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2430 if(jd->buddies != NULL)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2431 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2432 g_hash_table_foreach_remove(jd->buddies, jabber_destroy_buddy_hash, NULL);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2433 g_hash_table_destroy(jd->buddies);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2434 jd->buddies = NULL;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2435 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2436
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2437 /* Free-up the pending queries memories and the list */
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2438 if(jd->gjc != NULL && jd->gjc->queries != NULL) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2439 g_hash_table_foreach_remove(jd->gjc->queries, jabber_destroy_hash, NULL);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2440 g_hash_table_destroy(jd->gjc->queries);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2441 jd->gjc->queries = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2442 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2443 }
2300
d2686f757d6e [gaim-migrate @ 2310]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
2444 if (gc->inpa)
d2686f757d6e [gaim-migrate @ 2310]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
2445 gaim_input_remove(gc->inpa);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2446
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2447 if(jd) {
3613
95669ff6dc3b [gaim-migrate @ 3727]
Sean Egan <seanegan@gmail.com>
parents: 3596
diff changeset
2448 g_timeout_add(0, jabber_free, jd);
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2449 if(jd->gjc != NULL)
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2450 xmlnode_free(jd->gjc->current);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2451 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2452 gc->proto_data = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2453 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2454
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2455 static int jabber_send_typing(GaimConnection *gc, char *who, int typing)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2456 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2457 xmlnode x, y;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2458 char *realwho;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2459 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2460 jab_res_info jri = jabber_find_resource(gc, who);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2461
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2462 if(!jri || !jri->has_composing)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2463 return 0;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2464
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2465 if((realwho = get_realwho(gjc, who, FALSE, NULL)) == NULL)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2466 return 0;
3596
bb966d68f9e3 [gaim-migrate @ 3698]
Mark Doliner <mark@kingant.net>
parents: 3583
diff changeset
2467
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2468 x = xmlnode_new_tag("message");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2469 xmlnode_put_attrib(x, "to", realwho);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2470
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2471 y = xmlnode_insert_tag(x, "x");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2472 xmlnode_put_attrib(y, "xmlns", "jabber:x:event");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2473
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
2474 if(typing == GAIM_TYPING)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2475 xmlnode_insert_tag(y, "composing");
3596
bb966d68f9e3 [gaim-migrate @ 3698]
Mark Doliner <mark@kingant.net>
parents: 3583
diff changeset
2476
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2477 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2478 xmlnode_free(x);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2479 g_free(realwho);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2480 return JABBER_TYPING_NOTIFY_INT;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2481 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2482
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2483 static void insert_message(xmlnode x, const char *message, gboolean use_xhtml) {
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2484 xmlnode y;
5110
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2485 char *buf = g_strdup_printf("<html xmlns='http://jabber.org/protocol/xhtml-im'><body>%s</body></html>", message);
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2486 char *xhtml, *plain;
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2487
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2488 html_to_xhtml(buf, &xhtml, &plain);
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2489 g_free(buf);
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2490
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2491 y = xmlnode_insert_tag(x, "body");
5110
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2492 xmlnode_insert_cdata(y, plain, -1);
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2493 g_free(plain);
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2494
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2495 if(use_xhtml) {
5110
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2496 y = xmlnode_str(xhtml, strlen(xhtml));
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2497 if(y) {
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2498 xmlnode_insert_tag_node(x, y);
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2499 xmlnode_free(y);
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2500 } else {
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2501 gaim_debug(GAIM_DEBUG_ERROR, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2502 "holy cow, html_to_xhtml didn't work right!\n");
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2503 gaim_debug(GAIM_DEBUG_ERROR, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2504 "the invalid XML: %s\n", xhtml);
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2505 }
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2506 }
5110
496ea7c1b77b [gaim-migrate @ 5473]
Nathan Walp <nwalp@pidgin.im>
parents: 5093
diff changeset
2507 g_free(xhtml);
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2508 }
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2509
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2510 static int jabber_send_im(GaimConnection *gc, const char *who, const char *message, int len, int flags)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2511 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2512 xmlnode x, y;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2513 char *thread_id = NULL;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2514 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2515 jab_res_info jri = jabber_find_resource(gc, who);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2516
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2517 if (!who || !message)
2123
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2112
diff changeset
2518 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2519
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2520 x = xmlnode_new_tag("message");
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
2521 xmlnode_put_attrib(x, "to", who);
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
2522
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
2523 thread_id = jabber_get_convo_thread(gjc, who);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2524 if(thread_id)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2525 {
3769
303e40b66b96 [gaim-migrate @ 3908]
Sean Egan <seanegan@gmail.com>
parents: 3768
diff changeset
2526 if(strcmp(thread_id, "")) {
303e40b66b96 [gaim-migrate @ 3908]
Sean Egan <seanegan@gmail.com>
parents: 3768
diff changeset
2527 y = xmlnode_insert_tag(x, "thread");
303e40b66b96 [gaim-migrate @ 3908]
Sean Egan <seanegan@gmail.com>
parents: 3768
diff changeset
2528 xmlnode_insert_cdata(y, thread_id, -1);
303e40b66b96 [gaim-migrate @ 3908]
Sean Egan <seanegan@gmail.com>
parents: 3768
diff changeset
2529 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2530 g_free(thread_id);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2531 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2532
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2533 xmlnode_put_attrib(x, "type", "chat");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2534
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2535 /* let other clients know we support typing notification */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2536 y = xmlnode_insert_tag(x, "x");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2537 xmlnode_put_attrib(y, "xmlns", "jabber:x:event");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2538 xmlnode_insert_tag(y, "composing");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2539
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2540 if (message && strlen(message)) {
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
2541 insert_message(x, message, jri ? jri->has_xhtml : TRUE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2542 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2543
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2544 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2545 xmlnode_free(x);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2300
diff changeset
2546 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2547 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2548
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2549 /*
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2550 * Add/update buddy's roster entry on server
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2551 *
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2552 * If "alias" or "group" are NULL, gets them from Gaim's current buddylist values
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2553 * for the buddy.
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2554 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2555 static void jabber_roster_update(GaimConnection *gc, const char *name, const char *alias, const char *group)
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2556 {
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2557 xmlnode x, y;
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2558 char *realwho;
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2559 gjconn gjc;
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2560 struct buddy *buddy = NULL;
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2561 struct group *buddy_group = NULL;
3867
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3770
diff changeset
2562 const char *my_alias = NULL;
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3770
diff changeset
2563 const char *my_group = NULL;
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
2564
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2565 if(gc && gc->proto_data && ((struct jabber_data *)gc->proto_data)->gjc && name) {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2566 gaim_jid gjid;
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2567 gjc = ((struct jabber_data *)gc->proto_data)->gjc;
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2568
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2569 if((realwho = get_realwho(gjc, name, FALSE, &gjid)) == NULL)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2570 return;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2571
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2572 /* FIXME: transport */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2573 if(gjid->user == NULL) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2574 g_free(realwho);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2575 gaim_jid_free(gjid);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2576 return;
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2577 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2578 gaim_jid_free(gjid);
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2579
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2580 x = jutil_iqnew(JPACKET__SET, NS_ROSTER);
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2581 y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item");
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2582 xmlnode_put_attrib(y, "jid", realwho);
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2583
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
2584 buddy = gaim_find_buddy(gc->account, realwho);
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4333
diff changeset
2585
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2586 /*
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2587 * See if there's an explict (new?) alias for the buddy or we can pull
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2588 * one out of current Gaim buddylist data for him.
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2589 */
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2590 if(alias && alias[0] != '\0') {
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2591 my_alias = alias;
4705
e34fe984f999 [gaim-migrate @ 5016]
Nathan Walp <nwalp@pidgin.im>
parents: 4690
diff changeset
2592 } else if(buddy && buddy->alias) {
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4115
diff changeset
2593 my_alias = buddy->alias;
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2594 }
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2595
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2596 /* If there's an alias for the buddy, it's not 0-length
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2597 * and it doesn't match his JID, add the "name" attribute.
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2598 */
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2599 if(my_alias != NULL && my_alias[0] != '\0' && strcmp(realwho, my_alias))
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2600 {
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2601 xmlnode_put_attrib(y, "name", my_alias);
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2602 }
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2603
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2604 /*
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2605 * See if there's an explict (new?) group for the buddy or pull
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2606 * one out of current Gaim buddylist data for him.
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2607 */
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2608 if(group && group[0] != '\0') {
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2609 my_group = group;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
2610 } else if((buddy_group = gaim_find_buddys_group(buddy)) != NULL) {
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2611 my_group = buddy_group->name;
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2612 }
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2613
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2614 /*
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2615 * Send what group the buddy's in along with the roster item.
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2616 */
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2617 if(my_group != NULL && my_group[0] != '\0') {
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2618 xmlnode z = xmlnode_insert_tag(y, "group");
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2619 xmlnode_insert_cdata(z, my_group, -1);
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2620 }
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2621
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2622 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2623
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2624 xmlnode_free(x);
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2625 g_free(realwho);
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2626 }
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2627 }
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2628
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
2629 /*
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2630 * Add/update buddy's alias on server
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2631 *
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2632 * This is just a roster update using existing, local buddylist data
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2633 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2634 static void jabber_alias_buddy(GaimConnection *gc, const char *name, const char *alias)
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2635 {
4269
ff0642fab1d5 [gaim-migrate @ 4520]
Mark Doliner <mark@kingant.net>
parents: 4249
diff changeset
2636 jabber_roster_update(gc, name, alias, NULL);
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2637 }
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2638
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2639 /*
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
2640 * Change buddy's group on server roster
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
2641 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2642 static void jabber_group_change(GaimConnection *gc, const char *name, const char *old_group, const char *new_group)
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
2643 {
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2644 if(old_group && new_group && strcmp(old_group, new_group))
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2645 jabber_roster_update(gc, name, NULL, new_group);
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2646 }
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2647
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2648 /*
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2649 * Group rename
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2650 *
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2651 * Jabber doesn't have "groups," per se. "Group" is simply a JID attribute.
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2652 * So we iterate through the list of buddies that are in the group and change
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2653 * the group attribute for each of them.
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2654 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2655 static void jabber_rename_group(GaimConnection *gc,
3867
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3770
diff changeset
2656 const char *old_group,
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3770
diff changeset
2657 const char *new_group,
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2658 GList *members)
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2659 {
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2660 if(old_group && new_group && strcmp(old_group, new_group))
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2661 while(members) {
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2662 jabber_group_change(gc, (char *)(members->data), old_group, new_group);
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2663 members = members->next;
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2664 }
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
2665 }
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
2666
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2667 static void jabber_add_buddy(GaimConnection *gc, const char *name)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2668 {
3136
1bd472b7f7a2 [gaim-migrate @ 3151]
Rob Flynn <gaim@robflynn.com>
parents: 3105
diff changeset
2669 xmlnode x;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2670 char *realwho;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2671 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2672 gaim_jid gjid;
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2673 GaimAccount *account = gaim_connection_get_account(gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2674
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2675 if (!((struct jabber_data *)gc->proto_data)->did_import)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2676 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2677
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2678 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2679 * If there's no name or the name is ourself
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2680 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2681 if(!name || !strcmp(gaim_account_get_username(account), name))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2682 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2683
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2684 if((realwho = get_realwho(gjc, name, FALSE, &gjid)) == NULL) {
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3349
diff changeset
2685 char *msg = g_strdup_printf(_("The user %s is an invalid Jabber I.D. and was "
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3349
diff changeset
2686 "therefore not added."), name);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
2687 gaim_notify_error(gc, NULL, _("Unable to add buddy."),
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
2688 _("Jabber Error"));
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2689 g_free(msg);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2690 jabber_remove_gaim_buddy(gc, name);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2691 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2692 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2693
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2694 /* FIXME: transport */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2695 if(gjid->user == NULL) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2696 g_free(realwho);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2697 gaim_jid_free(gjid);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2698 return;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2699 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2700 gaim_jid_free(gjid);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2701
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2702 x = xmlnode_new_tag("presence");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2703 xmlnode_put_attrib(x, "to", realwho);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2704 xmlnode_put_attrib(x, "type", "subscribe");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2705 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2706 xmlnode_free(x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2707
3349
000546860da7 [gaim-migrate @ 3368]
Jim Seymour <jseymour>
parents: 3340
diff changeset
2708 jabber_roster_update(gc, realwho, NULL, NULL);
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
2709
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2710 g_free(realwho);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2711 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2712
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2713 static void jabber_remove_buddy(GaimConnection *gc, char *name, char *group)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2714 {
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
2715 xmlnode x;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2716 char *realwho;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2717 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2718
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2719 if(!name || (realwho = get_realwho(gjc, name, FALSE, NULL)) == NULL)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2720 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2721
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2722 x = xmlnode_new_tag("presence");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2723 xmlnode_put_attrib(x, "to", realwho);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2724 xmlnode_put_attrib(x, "type", "unsubscribe");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2725 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2726 g_free(realwho);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2727 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2728 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2729
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2730 #if 0 /* Faceprint! Look here! */
3314
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
2731 /*
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
2732 * Remove a buddy item from the roster entirely
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
2733 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2734 static void jabber_remove_buddy_roster_item(GaimConnection *gc, char *name)
3314
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
2735 {
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2736 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
3314
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
2737 char *realwho;
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2738
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2739 if((realwho = get_realwho(gjc, name, FALSE, NULL)) != NULL) {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2740 xmlnode x = jutil_iqnew(JPACKET__SET, NS_ROSTER);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2741 xmlnode y = xmlnode_insert_tag(xmlnode_get_tag(x, "query"), "item");
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2742 xmlnode_put_attrib(y, "jid", realwho);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2743 xmlnode_put_attrib(y, "subscription", "remove");
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2744 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2745 g_free(realwho);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2746 xmlnode_free(x);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2747 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2748 }
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2749 #endif
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2750
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2751 /*
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2752 * Unsubscribe a buddy from our presence
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2753 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2754 static void jabber_unsubscribe_buddy_from_us(GaimConnection *gc, const char *name)
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2755 {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2756 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2757 char *realwho;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2758
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2759 if((realwho = get_realwho(gjc, name, FALSE, NULL)) != NULL) {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2760 xmlnode g = xmlnode_new_tag("presence");
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2761 xmlnode_put_attrib(g, "to", realwho);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2762 xmlnode_put_attrib(g, "type", "unsubscribed");
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2763 gjab_send(gjc, g);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2764 xmlnode_free(g);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2765 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2766 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2767
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2768 /*
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2769 * Common code for setting ourselves invisible/visible to buddy
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2770 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2771 static void jabber_invisible_to_buddy_common(GaimConnection *gc, const char *name, gboolean invisible)
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2772 {
3314
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
2773 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2774 char *realwho;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2775
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2776 if((realwho = get_realwho(gjc, name, FALSE, NULL)) != NULL) {
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2777 struct jabber_buddy_data *jbd = jabber_find_buddy(gc, realwho, TRUE);
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2778 xmlnode g = xmlnode_new_tag("presence");
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2779
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2780 xmlnode_put_attrib(g, "to", realwho);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2781
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2782 if(invisible)
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2783 xmlnode_put_attrib(g, "type", "invisible");
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2784
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2785 gjab_send(gjc, g);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2786
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2787 g_free(realwho);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2788 xmlnode_free(g);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2789
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2790 if(jbd) {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2791 if(invisible) {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2792 jbd->invisible |= JABBER_BUD_INVIS;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2793 } else {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2794 jbd->invisible &= ~JABBER_BUD_INVIS;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2795 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2796 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2797 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2798 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2799
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2800 /*
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2801 * Make ourselves temporarily invisible to a buddy
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2802 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2803 static void jabber_invisible_to_buddy(GaimConnection *gc, const char *name)
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2804 {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2805 jabber_invisible_to_buddy_common(gc, name, TRUE);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2806 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2807
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2808 /*
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2809 * Make ourselves visible to a buddy
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2810 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2811 static void jabber_visible_to_buddy(GaimConnection *gc, const char *name)
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2812 {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2813 jabber_invisible_to_buddy_common(gc, name, FALSE);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2814 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2815
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2816 /*
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2817 * Function used by the g_hash_table_foreach() in invisible_to_all_buddies() to
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2818 * actually set the status.
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2819 *
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2820 * key is unused
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2821 * value is the pointer to the jabber_buddy_data struct
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2822 * data is gboolean: TRUE (invisible) or FALSE (not invisible)
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2823 */
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2824 static void set_invisible_to_buddy_status(gpointer key, gpointer val, gpointer data) {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2825 struct jabber_buddy_data *jbd = val;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2826 gboolean invisible = (gboolean) data;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2827
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2828 if(jbd) {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2829 if(invisible) {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2830 jbd->invisible = JABBER_SERV_INVIS | JABBER_BUD_INVIS;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2831 } else {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2832 /*
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2833 * If we've asserted server-level invisibility, cancelling
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2834 * it removes explicit buddy invisibility settings too.
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2835 */
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2836 if(jbd->invisible & JABBER_SERV_INVIS)
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2837 jbd->invisible = JABBER_NOT_INVIS;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2838 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2839 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2840 }
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2841
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2842 /*
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2843 * Show we've set ourselves invisible/visible to all buddies on the server
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2844 *
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2845 * Used when we set server-wide invisibility so that individual buddy menu
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2846 * entries show the proper option.
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2847 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2848 static void invisible_to_all_buddies(GaimConnection *gc, gboolean invisible)
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2849 {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2850 struct jabber_data *jd = gc->proto_data;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2851
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2852 if(jd->buddies != NULL)
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
2853 g_hash_table_foreach(jd->buddies, set_invisible_to_buddy_status, (gpointer) invisible);
3314
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
2854 }
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
2855
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2856 static const char *jabber_list_icon(GaimAccount *a, struct buddy *b)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2857 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
2858 return "jabber";
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
2859 }
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2860
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2861 static void jabber_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne)
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2862 {
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2863 struct jabber_buddy_data *jbd = jabber_find_buddy(b->account->gc, b->name, FALSE);
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2864
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2865 if(!GAIM_BUDDY_IS_ONLINE(b)) {
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2866 if (jbd && jbd->error_msg)
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
2867 *nw = "error";
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2868
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2869 if(jbd && (jbd->subscription & JABBER_SUB_PENDING ||
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2870 !(jbd->subscription & JABBER_SUB_TO)))
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2871 *se = "notauthorized";
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2872 else
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2873 *se = "offline";
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
2874
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2875 } else {
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2876 switch (b->uc) {
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2877 case UC_AWAY:
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2878 *se = "away";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2879 break;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2880 case UC_CHAT:
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2881 *se = "chat";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2882 break;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2883 case UC_XA:
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2884 *se = "extendedaway";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2885 break;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2886 case UC_DND:
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2887 *se = "dnd";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2888 break;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2889 case UC_ERROR:
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2890 *se = "error";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2891 break;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2892 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2893 }
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
2894 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2895
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2896 static GList *jabber_chat_info(GaimConnection *gc)
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2897 {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2898 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2899
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2900 static char *confserv = NULL; /* this pointer must be persistent */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2901 gchar *server;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2902
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2903 GList *m = NULL;
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2904 struct proto_chat_entry *pce;
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2905
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2906 /* This is a scientific wild-ass guess...
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2907 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2908 * If there are more than two "components" to the current server name,
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2909 * lop-off the left-most component and replace with "conference."
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2910 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2911 if(confserv != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2912 g_free(confserv); /* dispose of the old value */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2913 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2914
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2915 if((server = g_strdup(gjc->user->server)) == NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2916 confserv = g_strdup(DEFAULT_GROUPCHAT);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2917 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2918 gchar **splits, **index;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2919 gchar *tmp;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2920 int cnt = 0;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2921
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2922
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2923 index = splits = g_strsplit(server, ".", -1); /* split the connected server */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2924
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2925 while(*(index++)) /* index to the end--counting the parts */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2926 ++cnt;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2927
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2928 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2929 * If we've more than two parts, point to the second part. Else point
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2930 * to the start.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2931 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2932 if(cnt > 2) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2933 index -= cnt;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2934 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2935 index = splits;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2936 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2937
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2938 /* Put it together */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2939 confserv = g_strjoin(".", "conference", (tmp = g_strjoinv(".", index)), NULL);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2940
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2941 g_free(server); /* we don't need this stuff no more */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2942 g_free(tmp);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2943 g_strfreev(splits);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2944 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2945
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2946 pce = g_new0(struct proto_chat_entry, 1);
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2947 pce->label = _("Room:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2948 pce->identifier = "room";
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2949 m = g_list_append(m, pce);
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2950
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2951 pce = g_new0(struct proto_chat_entry, 1);
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2952 pce->label = _("Server:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2953 pce->identifier = "server";
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2954 pce->def = confserv;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2955 m = g_list_append(m, pce);
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2956
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2957 pce = g_new0(struct proto_chat_entry, 1);
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2958 pce->label = _("Handle:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2959 pce->identifier = "handle";
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2960 pce->def = gjc->user->user;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2961 m = g_list_append(m, pce);
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2962
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2963 return m;
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2964 }
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2965
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
2966 static void jabber_join_chat(GaimConnection *gc, GHashTable *data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2967 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2968 xmlnode x;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2969 char *room, *server, *handle;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2970 char *realwho;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2971 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2972 GSList *jcs = ((struct jabber_data *)gc->proto_data)->chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2973 struct jabber_chat *jc;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2974 gaim_jid gjid;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2975
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2976 room = g_hash_table_lookup(data, "room");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2977 server = g_hash_table_lookup(data, "server");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2978 handle = g_hash_table_lookup(data, "handle");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2979
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2980 if (!room || !server || !handle)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2981 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2982
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2983 realwho = create_valid_jid(room, server, handle);
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
2984 gaim_debug(GAIM_DEBUG_INFO, "jabber", "%s\n", realwho);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2985
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2986 if((gjid = gaim_jid_new(realwho)) == NULL) {
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3349
diff changeset
2987 char *msg = g_strdup_printf("The Jabber I.D. %s is invalid.", realwho);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
2988 gaim_notify_error(gc, NULL, _("Unable to join chat"), msg);
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2989 g_free(msg);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2990 g_free(realwho);
3236
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2991 return;
6796fdeed022 [gaim-migrate @ 3253]
Jim Seymour <jseymour>
parents: 3234
diff changeset
2992 }
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2993
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
2994 if((jc = find_any_chat(gc, gjid)) != NULL) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2995 switch(jc->state) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2996 case JCS_PENDING:
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2997 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
2998 "attempt to re-join already pending Jabber chat! (ignoring)\n");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
2999 g_free(realwho); /* yuck! */
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3000 gaim_jid_free(gjid);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3001 return;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3002 case JCS_ACTIVE:
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3003 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3004 "attempt to re-join already active Jabber chat! (ignoring)\n");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3005 g_free(realwho); /* yuck! */
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3006 gaim_jid_free(gjid);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3007 return;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3008 case JCS_CLOSED:
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3009 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3010 "rejoining previously closed Jabber chat\n");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3011 break;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3012 default:
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3013 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3014 "found Jabber chat in unknown state! (ignoring)\n");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3015 g_free(realwho); /* yuck! */
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3016 gaim_jid_free(gjid);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3017 return;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3018 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3019 } else {
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3020 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3021 "joining completely new Jabber chat\n");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3022 jc = g_new0(struct jabber_chat, 1);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3023 jc->gjid = gjid;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3024 jc->gc = gc;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3025 ((struct jabber_data *)gc->proto_data)->chats = g_slist_append(jcs, jc);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
3026 // add_buddy(gc->account, _("Chats"), realwho, realwho);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3027 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3028
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3029 jc->state = JCS_PENDING;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3030
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3031 x = jutil_presnew(0, realwho, NULL);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3032 gjab_send(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3033 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3034 g_free(realwho);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3035 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3036
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3037 static void jabber_chat_invite(GaimConnection *gc, int id, const char *message, const char *name)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3038 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3039 xmlnode x, y;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3040 struct jabber_data *jd = gc->proto_data;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3041 gjconn gjc = jd->gjc;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
3042 struct jabber_chat *jc = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3043 char *realwho, *subject;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3044
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3045 if(!name || (realwho = get_realwho(gjc, name, FALSE, NULL)) == NULL)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3046 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3047
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3048 /* find which chat we're inviting to */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3049 if(jabber_find_chat_by_convo_id(gc, id, &jc) != 0)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3050 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3051
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3052 x = xmlnode_new_tag("message");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3053 xmlnode_put_attrib(x, "to", realwho);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3054
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3055 g_free(realwho);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3056
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3057 y = xmlnode_insert_tag(x, "x");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3058 xmlnode_put_attrib(y, "xmlns", "jabber:x:conference");
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3059 subject = g_strdup_printf("%s@%s", jc->gjid->user, jc->gjid->server);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3060 xmlnode_put_attrib(y, "jid", subject);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3061 g_free(subject);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3062
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3063 if (message && strlen(message)) {
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
3064 insert_message(x, message, FALSE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3065 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3066
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3067 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3068 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3069 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3070
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3071 static void jabber_chat_leave(GaimConnection *gc, int id)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3072 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3073 struct jabber_data *jd = gc->proto_data;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3074 gjconn gjc = jd->gjc;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
3075 struct jabber_chat *jc = NULL;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3076 char *chatname;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3077 xmlnode x;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3078
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3079 /* Find out which chat we're leaving */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3080 if(jabber_find_chat_by_convo_id(gc, id, &jc) != 0)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3081 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3082
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3083 chatname = g_strdup_printf("%s@%s", jc->gjid->user, jc->gjid->server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3084 x = jutil_presnew(0, chatname, NULL);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3085 g_free(chatname);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3086 xmlnode_put_attrib(x, "type", "unavailable");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3087 gjab_send(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3088 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3089 jc->b = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3090 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3091
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3092 static int jabber_chat_send(GaimConnection *gc, int id, char *message)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3093 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3094 xmlnode x, y;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
3095 struct jabber_chat *jc = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3096 char *chatname;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3097 int retval = 0;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3098
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3099 /* Find out which chat we're sending to */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3100 if((retval = jabber_find_chat_by_convo_id(gc, id, &jc)) != 0)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3101 return(retval);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3102
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3103 x = xmlnode_new_tag("message");
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3104 xmlnode_put_attrib(x, "from", jc->gjid->full);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3105 chatname = g_strdup_printf("%s@%s", jc->gjid->user, jc->gjid->server);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3106 xmlnode_put_attrib(x, "to", chatname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3107 g_free(chatname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3108 xmlnode_put_attrib(x, "type", "groupchat");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3109
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2278
diff changeset
3110 if (message && strlen(message) > strlen("/topic ") &&
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4777
diff changeset
3111 !g_ascii_strncasecmp(message, "/topic ", strlen("/topic "))) {
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2278
diff changeset
3112 char buf[8192];
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2278
diff changeset
3113 y = xmlnode_insert_tag(x, "subject");
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
3114 xmlnode_insert_cdata(y, message + strlen("/topic "), -1);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2278
diff changeset
3115 y = xmlnode_insert_tag(x, "body");
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
3116 g_snprintf(buf, sizeof(buf), "/me has changed the subject to: %s", message + strlen("/topic"));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2278
diff changeset
3117 xmlnode_insert_cdata(y, buf, -1);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2278
diff changeset
3118 } else if (message && strlen(message)) {
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
3119 insert_message(x, message, FALSE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3120 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3121
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3122 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3123 xmlnode_free(x);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
3124 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3125 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3126
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3127 static void jabber_chat_whisper(GaimConnection *gc, int id, char *who, char *message)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3128 {
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
3129 xmlnode x;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
3130 struct jabber_chat *jc = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3131 char *chatname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3132
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3133 /* Find out which chat we're whispering to */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3134 if(jabber_find_chat_by_convo_id(gc, id, &jc) != 0)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3135 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3136
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3137 x = xmlnode_new_tag("message");
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3138 xmlnode_put_attrib(x, "from", jc->gjid->full);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3139 chatname = g_strdup_printf("%s@%s/%s", jc->gjid->user, jc->gjid->server, who);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3140 xmlnode_put_attrib(x, "to", chatname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3141 g_free(chatname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3142 xmlnode_put_attrib(x, "type", "normal");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3143
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3144 if (message && strlen(message)) {
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
3145 insert_message(x, message, FALSE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3146 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3147
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3148 gjab_send(((struct jabber_data *)gc->proto_data)->gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3149 xmlnode_free(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3150 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3151
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3152 static char *jabber_normalize(const char *s)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3153 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3154 static char buf[BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3155 char *t, *u;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3156 int x = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3157
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3158 g_return_val_if_fail((s != NULL), NULL);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3159
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3160 /* Somebody called us with s == NULL once... */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3161 if(s == NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3162 return(NULL);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3163 } else {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4777
diff changeset
3164 u = t = g_utf8_strdown(s, -1);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3165
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3166 while (*t && (x < BUF_LEN - 1)) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3167 if (*t != ' ')
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3168 buf[x++] = *t;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3169 t++;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3170 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3171 buf[x] = '\0';
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3172 g_free(u);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3173
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3174 if (!strchr(buf, '@')) {
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
3175 strcat(buf, "@" DEFAULT_SERVER); /* this isn't always right, but eh */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3176 } else if ((u = strchr(strchr(buf, '@'), '/')) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3177 *u = '\0';
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3178 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3179
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3180 return buf;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3181 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3182 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3183
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3184 static void jabber_get_info(GaimConnection *gc, const char *who) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3185 xmlnode x;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3186 char *id;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3187 char *realwho;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3188 struct jabber_data *jd = gc->proto_data;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3189 gjconn gjc = jd->gjc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3190
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3191 if((realwho = get_realwho(gjc, who, TRUE, NULL)) == NULL)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3192 return;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3193
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3194 x = jutil_iqnew(JPACKET__GET, NS_VCARD);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3195 xmlnode_put_attrib(x, "to", realwho);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3196
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3197 g_free(realwho);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3198
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3199 id = gjab_getid(gjc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3200 xmlnode_put_attrib(x, "id", id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3201
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3202 g_hash_table_insert(jd->gjc->queries, g_strdup(id), g_strdup("vCard"));
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3203
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3204 gjab_send(gjc, x);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3205
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3206 xmlnode_free(x);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3207 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3208
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3209 static void jabber_get_error_msg(GaimConnection *gc, const char *who) {
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3210 struct jabber_data *jd = gc->proto_data;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3211 gjconn gjc = jd->gjc;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3212 gchar **str_arr = (gchar **) g_new(gpointer, 3);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3213 gchar **ap = str_arr;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3214 gchar *realwho, *final;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3215 struct jabber_buddy_data *jbd;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3216
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3217 if((realwho = get_realwho(gjc, who, FALSE, NULL)) == NULL) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3218 g_strfreev(str_arr);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3219 return;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3220 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3221
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3222 jbd = jabber_find_buddy(gc, realwho, TRUE);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3223
5236
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3224 *ap++ = g_strdup_printf("<B>%s:</B> %s<BR>\n", _("Jabber ID"), realwho);
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3225 *ap++ = g_strdup_printf("<B>%s:</B> %s<BR>\n", _("Error"), jbd->error_msg);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3226 *ap = NULL;
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
3227
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3228 final= g_strjoinv(NULL, str_arr);
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
3229
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3230 g_strfreev(str_arr);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3231
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3232 g_show_info_text(gc, realwho, 2, final, NULL);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3233 g_free(realwho);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3234 g_free(final);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3235 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3236
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3237 static void jabber_get_away_msg(GaimConnection *gc, const char *who) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3238 struct jabber_data *jd = gc->proto_data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3239 gjconn gjc = jd->gjc;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3240 int num_resources;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3241 gaim_jid gjid;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3242 char *buddy = get_realwho(gjc, who, FALSE, &gjid);
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3243 struct jabber_buddy_data *jbd = jabber_find_buddy(gc, buddy, TRUE);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3244 gchar **str_arr;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3245 gchar **ap;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3246 gchar *realwho, *final;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3247 GSList *resources;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3248 int i;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3249
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3250 if(!buddy)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3251 return;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3252
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3253 if(!gjid->resource) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3254 num_resources = g_slist_length(jbd->resources);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3255 resources = jbd->resources;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3256 } else {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3257 num_resources = 1;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3258 resources = jbd->resources;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3259 while(strcasecmp(((jab_res_info)resources->data)->name, gjid->resource))
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3260 resources = resources->next;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3261 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3262
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3263 gaim_jid_free(gjid);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3264
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3265 /* space for all elements: Jabber I.D. + "status" + NULL (list terminator) */
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3266 str_arr = (gchar **) g_new(gpointer, num_resources*2 + 1);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3267 ap = str_arr;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3268
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3269 for(i=0; i<num_resources; i++)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3270 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3271 jab_res_info jri = resources->data;
4450
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
3272 char *status;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3273 realwho = g_strdup_printf("%s/%s", buddy, jri->name);
4450
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
3274 status = strdup_withhtml(jabber_lookup_away(gjc, realwho));
5236
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3275 *ap++ = g_strdup_printf("<B>%s:</B> %s<BR>\n", _("Jabber ID"), realwho);
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3276 *ap++ = g_strdup_printf("<B>%s:</B> %s%s%s<BR>\n", _("Status"), jabber_get_state_string(jri->state), status ? ": " : "", status ? status : "");
4450
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
3277 g_free(status);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3278 g_free(realwho);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3279 resources = resources->next;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3280 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3281
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3282 *ap = NULL;
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
3283
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3284 g_free(buddy);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3285
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3286 final= g_strjoinv(NULL, str_arr);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3287 g_strfreev(str_arr);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3288
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3289 g_show_info_text(gc, who, 2, final, NULL);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3290 g_free(final);
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
3291
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3292 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3293
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3294 static void jabber_get_cb_info(GaimConnection *gc, int cid, char *who) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3295 struct jabber_chat *jc = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3296 char *realwho;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3297
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3298 /* Find out which chat */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3299 if(jabber_find_chat_by_convo_id(gc, cid, &jc) != 0)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3300 return;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3301
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3302 realwho = g_strdup_printf("%s@%s/%s", jc->gjid->user, jc->gjid->server, who);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3303
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3304 jabber_get_info(gc, realwho);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3305 g_free(realwho);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3306 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3307
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3308 static void jabber_get_cb_away_msg(GaimConnection *gc, int cid, char *who) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3309 struct jabber_chat *jc = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3310 char *realwho;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3311
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3312 /* Find out which chat */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3313 if(jabber_find_chat_by_convo_id(gc, cid, &jc) != 0)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3314 return;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3315
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3316 realwho = g_strdup_printf("%s@%s/%s", jc->gjid->user, jc->gjid->server, who);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3317
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3318 jabber_get_away_msg(gc, realwho);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3319 g_free(realwho);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3320
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3321 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3322
4744
a0746ffce599 [gaim-migrate @ 5059]
Sean Egan <seanegan@gmail.com>
parents: 4732
diff changeset
3323 static char *jabber_tooltip_text(struct buddy *b)
a0746ffce599 [gaim-migrate @ 5059]
Sean Egan <seanegan@gmail.com>
parents: 4732
diff changeset
3324 {
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3325 struct jabber_buddy_data *jbd = jabber_find_buddy(b->account->gc, b->name, FALSE);
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3326 jab_res_info jri = jabber_find_resource(b->account->gc, b->name);
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3327 char *ret = NULL;
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3328 if(jri) {
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3329 char *stripped = strip_html(jabber_lookup_away(GC_GJ(b->account->gc),
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3330 b->name));
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3331 char *text = NULL;
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3332 if(stripped)
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3333 text = g_markup_escape_text(stripped, strlen(stripped));
5236
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3334 ret = g_strdup_printf("<b>%s:</b> %s%s%s",
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3335 _("Status"),
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3336 jabber_get_state_string(jri->state), text ? ": " : "",
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3337 text ? text : "");
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3338
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3339 if(stripped) {
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3340 g_free(stripped);
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3341 g_free(text);
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3342 }
5136
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3343 } else if(jbd && !GAIM_BUDDY_IS_ONLINE(b) &&
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3344 (jbd->subscription & JABBER_SUB_PENDING ||
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3345 !(jbd->subscription & JABBER_SUB_TO))) {
5236
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3346 ret = g_strdup_printf("<b>%s:</b> %s", _("Status"), _("Not Authorized"));
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3347 }
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3348 return ret;
4744
a0746ffce599 [gaim-migrate @ 5059]
Sean Egan <seanegan@gmail.com>
parents: 4732
diff changeset
3349 }
a0746ffce599 [gaim-migrate @ 5059]
Sean Egan <seanegan@gmail.com>
parents: 4732
diff changeset
3350
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
3351 static char *jabber_status_text(struct buddy *b)
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
3352 {
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3353 struct jabber_buddy_data *jbd = jabber_find_buddy(b->account->gc, b->name, FALSE);
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3354 char *ret = NULL;
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
3355 if (b->uc & UC_UNAVAILABLE) {
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3356 char *stripped = strip_html(jabber_lookup_away(GC_GJ(b->account->gc),
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3357 b->name));
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3358 if(!stripped) {
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3359 jab_res_info jri = jabber_find_resource(b->account->gc, b->name);
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3360 if(jri)
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3361 stripped = g_strdup(jabber_get_state_string(jri->state));
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3362 }
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3363 ret = g_markup_escape_text(stripped, strlen(stripped));
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
3364 g_free(stripped);
5136
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3365 } else if(jbd && !GAIM_BUDDY_IS_ONLINE(b) &&
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3366 (jbd->subscription & JABBER_SUB_PENDING ||
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3367 !(jbd->subscription & JABBER_SUB_TO))) {
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3368 ret = g_strdup(_("Not Authorized"));
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
3369 }
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3370 return ret;
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
3371 }
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
3372
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3373 static GList *jabber_buddy_menu(GaimConnection *gc, const char *who) {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
3374 GList *m = NULL;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
3375 struct proto_buddy_menu *pbm;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
3376 struct buddy *b = gaim_find_buddy(gc->account, who);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3377
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3378 if(b->uc == UC_ERROR)
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3379 {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3380 pbm = g_new0(struct proto_buddy_menu, 1);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3381 pbm->label = _("View Error Msg");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3382 pbm->callback = jabber_get_error_msg;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3383 pbm->gc = gc;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3384 m = g_list_append(m, pbm);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3385 } else {
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3386 gjconn gjc = ((struct jabber_data *)gc->proto_data)->gjc;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3387 char *realwho = get_realwho(gjc, who, FALSE, NULL);
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
3388 struct jabber_buddy_data *jbd = jabber_find_buddy(gc, realwho, FALSE);
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3389
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3390 g_free(realwho);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3391
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3392 pbm = g_new0(struct proto_buddy_menu, 1);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3393 pbm->label = _("Get Away Msg");
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3394 pbm->callback = jabber_get_away_msg;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3395 pbm->gc = gc;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3396 m = g_list_append(m, pbm);
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3397
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3398 pbm = g_new0(struct proto_buddy_menu, 1);
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3399 if(jbd && (jbd->invisible & JABBER_BUD_INVIS)) {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3400 pbm->label = _("Un-hide From");
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3401 pbm->callback = jabber_visible_to_buddy;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3402 } else {
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3403 pbm->label = _("Temporarily Hide From");
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3404 pbm->callback = jabber_invisible_to_buddy;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3405 }
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
3406
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
3407 pbm->gc = gc;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
3408 m = g_list_append(m, pbm);
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
3409 pbm = g_new0(struct proto_buddy_menu, 1);
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
3410 pbm->label = _("Cancel Presence Notification");
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
3411 pbm->callback = jabber_unsubscribe_buddy_from_us;
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3412 pbm->gc = gc;
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3413 m = g_list_append(m, pbm);
5136
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3414
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3415 if(jbd && !GAIM_BUDDY_IS_ONLINE(b) &&
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3416 !(jbd->subscription & JABBER_SUB_TO)) {
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3417 pbm = g_new0(struct proto_buddy_menu, 1);
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3418 pbm->label = _("Re-request authorization");
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3419 pbm->callback = jabber_add_buddy;
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3420 pbm->gc = gc;
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3421 m = g_list_append(m, pbm);
381da05cb5ed [gaim-migrate @ 5500]
Nathan Walp <nwalp@pidgin.im>
parents: 5135
diff changeset
3422 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3423 }
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
3424
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
3425 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3426 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3427
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3428 static GList *jabber_away_states(GaimConnection *gc) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3429 GList *m = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3430
4982
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3431 m = g_list_append(m, _("Online"));
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3432 m = g_list_append(m, _("Chatty"));
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3433 m = g_list_append(m, _("Away"));
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3434 m = g_list_append(m, _("Extended Away"));
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3435 m = g_list_append(m, _("Do Not Disturb"));
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3436 m = g_list_append(m, _("Invisible"));
4110
64d983d6b7bb [gaim-migrate @ 4325]
Luke Schierer <lschiere@pidgin.im>
parents: 4074
diff changeset
3437 m = g_list_append(m, GAIM_AWAY_CUSTOM);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3438
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3439 return m;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3440 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3441
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3442 static void jabber_set_away(GaimConnection *gc, char *state, char *message)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3443 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3444 xmlnode x, y;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3445 struct jabber_data *jd = gc->proto_data;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3446 gjconn gjc = jd->gjc;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3447 GSList *jcs;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3448 struct jabber_chat *jc;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3449 char *chatname;
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3450 gboolean invisible = FALSE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3451
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4110
diff changeset
3452 if (gc->away) {
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4110
diff changeset
3453 g_free(gc->away);
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4110
diff changeset
3454 gc->away = NULL;
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4110
diff changeset
3455 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3456
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3457 x = xmlnode_new_tag("presence");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3458
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3459 if (!strcmp(state, GAIM_AWAY_CUSTOM)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3460 /* oh goody. Gaim is telling us what to do. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3461 if (message) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3462 /* Gaim wants us to be away */
5174
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
3463 char *stripped;
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
3464
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
3465 /* Jabber supports XHTML in IMs, but not in away messages. */
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
3466 html_to_xhtml(message, NULL, &stripped);
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
3467
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3468 y = xmlnode_insert_tag(x, "show");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3469 xmlnode_insert_cdata(y, "away", -1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3470 y = xmlnode_insert_tag(x, "status");
5174
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
3471 xmlnode_insert_cdata(y, stripped, -1);
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
3472
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
3473 gc->away = g_strdup(stripped);
376349b04123 [gaim-migrate @ 5538]
Nathan Walp <nwalp@pidgin.im>
parents: 5136
diff changeset
3474 g_free(stripped);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3475 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3476 /* Gaim wants us to not be away */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3477 /* but for Jabber, we can just send presence with no other information. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3478 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3479 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3480 /* state is one of our own strings. it won't be NULL. */
4982
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3481 if (!strcmp(state, _("Online"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3482 /* once again, we don't have to put anything here */
4982
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3483 } else if (!strcmp(state, _("Chatty"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3484 y = xmlnode_insert_tag(x, "show");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3485 xmlnode_insert_cdata(y, "chat", -1);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4110
diff changeset
3486 gc->away = g_strdup("");
4982
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3487 } else if (!strcmp(state, _("Away"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3488 y = xmlnode_insert_tag(x, "show");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3489 xmlnode_insert_cdata(y, "away", -1);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4110
diff changeset
3490 gc->away = g_strdup("");
4982
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3491 } else if (!strcmp(state, _("Extended Away"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3492 y = xmlnode_insert_tag(x, "show");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3493 xmlnode_insert_cdata(y, "xa", -1);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4110
diff changeset
3494 gc->away = g_strdup("");
4982
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3495 } else if (!strcmp(state, _("Do Not Disturb"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3496 y = xmlnode_insert_tag(x, "show");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3497 xmlnode_insert_cdata(y, "dnd", -1);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4110
diff changeset
3498 gc->away = g_strdup("");
4982
fb232515839a [gaim-migrate @ 5317]
Nathan Walp <nwalp@pidgin.im>
parents: 4966
diff changeset
3499 } else if (!strcmp(state, _("Invisible"))) {
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3500 xmlnode_put_attrib(x, "type", "invisible");
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4110
diff changeset
3501 gc->away = g_strdup("");
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3502 invisible = TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3503 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3504 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3505
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3506 gjab_send(gjc, x); /* Notify "individuals" */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3507
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3508 /*
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3509 * As of jabberd-1.4.2: simply sending presence to the server doesn't result in
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3510 * it being propagated to conference rooms. So we wade thru the list of chats,
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3511 * sending our new presence status to each and every one.
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3512 */
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3513 for(jcs = jd->chats; jcs; jcs = jcs->next) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3514 jc = jcs->data;
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3515 if(jc->state == JCS_ACTIVE) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3516 xmlnode_put_attrib(x, "from", jc->gjid->full);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3517 chatname = g_strdup_printf("%s@%s", jc->gjid->user, jc->gjid->server);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3518 xmlnode_put_attrib(x, "to", chatname);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3519 gjab_send(gjc, x);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3520 g_free(chatname);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3521 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3522 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3523
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3524 xmlnode_free(x);
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3525
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
3526 invisible_to_all_buddies(gc, invisible);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3527 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3528
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3529 static void jabber_set_idle(GaimConnection *gc, int idle) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3530 struct jabber_data *jd = (struct jabber_data *)gc->proto_data;
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3531 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3532 "jabber_set_idle: setting idle %i\n", idle);
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
3533 jd->idle = idle ? time(NULL) - idle : idle;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3534 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3535
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3536 static void jabber_keepalive(GaimConnection *gc) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3537 struct jabber_data *jd = (struct jabber_data *)gc->proto_data;
4450
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
3538 gjab_send_raw(jd->gjc, JABBER_KEEPALIVE_STRING);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3539 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3540
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3541 /*---------------------------------------*/
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3542 /* Jabber "set info" (vCard) support */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3543 /*---------------------------------------*/
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3544
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3545 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3546 * V-Card format:
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3547 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3548 * <vCard prodid='' version='' xmlns=''>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3549 * <FN></FN>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3550 * <N>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3551 * <FAMILY/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3552 * <GIVEN/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3553 * </N>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3554 * <NICKNAME/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3555 * <URL/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3556 * <ADR>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3557 * <STREET/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3558 * <EXTADD/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3559 * <LOCALITY/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3560 * <REGION/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3561 * <PCODE/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3562 * <COUNTRY/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3563 * </ADR>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3564 * <TEL/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3565 * <EMAIL/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3566 * <ORG>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3567 * <ORGNAME/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3568 * <ORGUNIT/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3569 * </ORG>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3570 * <TITLE/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3571 * <ROLE/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3572 * <DESC/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3573 * <BDAY/>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3574 * </vCard>
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3575 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3576 * See also:
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3577 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3578 * http://docs.jabber.org/proto/html/vcard-temp.html
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3579 * http://www.vcard-xml.org/dtd/vCard-XML-v2-20010520.dtd
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3580 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3581
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3582 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3583 * Cross-reference user-friendly V-Card entry labels to vCard XML tags
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3584 * and attributes.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3585 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3586 * Order is (or should be) unimportant. For example: we have no way of
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3587 * knowing in what order real data will arrive.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3588 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3589 * Format: Label, Pre-set text, "visible" flag, "editable" flag, XML tag
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3590 * name, XML tag's parent tag "path" (relative to vCard node).
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3591 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3592 * List is terminated by a NULL label pointer.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3593 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3594 * Entries with no label text, but with XML tag and parent tag
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3595 * entries, are used by V-Card XML construction routines to
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3596 * "automagically" construct the appropriate XML node tree.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3597 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3598 * Thoughts on future direction/expansion
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3599 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3600 * This is a "simple" vCard.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3601 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3602 * It is possible for nodes other than the "vCard" node to have
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3603 * attributes. Should that prove necessary/desirable, add an
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3604 * "attributes" pointer to the vcard_template struct, create the
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3605 * necessary tag_attr structs, and add 'em to the vcard_dflt_data
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3606 * array.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3607 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3608 * The above changes will (obviously) require changes to the vCard
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3609 * construction routines.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3610 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3611
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3612 struct vcard_template {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3613 char *label; /* label text pointer */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3614 char *text; /* entry text pointer */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3615 int visible; /* should entry field be "visible?" */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3616 int editable; /* should entry field be editable? */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3617 char *tag; /* tag text */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3618 char *ptag; /* parent tag "path" text */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3619 char *url; /* vCard display format if URL */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3620 } vcard_template_data[] = {
2975
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3621 {N_("Full Name"), NULL, TRUE, TRUE, "FN", NULL, NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3622 {N_("Family Name"), NULL, TRUE, TRUE, "FAMILY", "N", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3623 {N_("Given Name"), NULL, TRUE, TRUE, "GIVEN", "N", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3624 {N_("Nickname"), NULL, TRUE, TRUE, "NICKNAME", NULL, NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3625 {N_("URL"), NULL, TRUE, TRUE, "URL", NULL, "<A HREF=\"%s\">%s</A>"},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3626 {N_("Street Address"), NULL, TRUE, TRUE, "STREET", "ADR", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3627 {N_("Extended Address"), NULL, TRUE, TRUE, "EXTADD", "ADR", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3628 {N_("Locality"), NULL, TRUE, TRUE, "LOCALITY", "ADR", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3629 {N_("Region"), NULL, TRUE, TRUE, "REGION", "ADR", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3630 {N_("Postal Code"), NULL, TRUE, TRUE, "PCODE", "ADR", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3631 {N_("Country"), NULL, TRUE, TRUE, "COUNTRY", "ADR", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3632 {N_("Telephone"), NULL, TRUE, TRUE, "TELEPHONE", NULL, NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3633 {N_("Email"), NULL, TRUE, TRUE, "EMAIL", NULL, "<A HREF=\"mailto:%s\">%s</A>"},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3634 {N_("Organization Name"), NULL, TRUE, TRUE, "ORGNAME", "ORG", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3635 {N_("Organization Unit"), NULL, TRUE, TRUE, "ORGUNIT", "ORG", NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3636 {N_("Title"), NULL, TRUE, TRUE, "TITLE", NULL, NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3637 {N_("Role"), NULL, TRUE, TRUE, "ROLE", NULL, NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3638 {N_("Birthday"), NULL, TRUE, TRUE, "BDAY", NULL, NULL},
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3639 {N_("Description"), NULL, TRUE, TRUE, "DESC", NULL, NULL},
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3640 {"", NULL, TRUE, TRUE, "N", NULL, NULL},
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3641 {"", NULL, TRUE, TRUE, "ADR", NULL, NULL},
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3642 {"", NULL, TRUE, TRUE, "ORG", NULL, NULL},
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3643 {NULL, NULL, 0, 0, NULL, NULL, NULL}
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3644 };
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3645
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3646 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3647 * The "vCard" tag's attibute list...
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3648 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3649 struct tag_attr {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3650 char *attr;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3651 char *value;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3652 } vcard_tag_attr_list[] = {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3653 {"prodid", "-//HandGen//NONSGML vGen v1.0//EN"},
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3654 {"version", "2.0", },
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3655 {"xmlns", "vcard-temp", },
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3656 {NULL, NULL},
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3657 };
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3658
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3659
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3660 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3661 * V-Card user instructions
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3662 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3663 static char *multi_entry_instructions =
2975
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3664 N_("All items below are optional. Enter only the information with which you feel comfortable");
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
3665 static char *entries_title = N_("User Identity");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3666
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3667 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3668 * Used by routines to parse an XML-encoded string into an xmlnode tree
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3669 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3670 typedef struct {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3671 XML_Parser parser;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3672 xmlnode current;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3673 } *xmlstr2xmlnode_parser, xmlstr2xmlnode_parser_struct;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3674
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3675
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3676 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3677 * Display a Jabber vCard
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3678 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3679 static void jabber_handlevcard(gjconn gjc, xmlnode querynode, char *from)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3680 {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
3681 GaimConnection *gc = GJ_GC(gjc);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3682 char *cdata, *status;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3683 struct vcard_template *vc_tp = vcard_template_data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3684
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3685 /* space for all vCard elements + Jabber I.D. + "status" + NULL (list terminator) */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3686 gchar **str_arr = (gchar **) g_new(gpointer,
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3687 (sizeof(vcard_template_data)/sizeof(struct vcard_template)) + 3);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3688 gchar **ap = str_arr;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3689 gchar *buddy, *final;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3690
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3691 jab_res_info jri;
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3692
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3693 if((buddy = get_realwho(gjc, from, TRUE, NULL)) == NULL) {
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3694 g_strfreev(str_arr);
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3695 return;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3696 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3697
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3698 jri = jabber_find_resource(GJ_GC(gjc), buddy);
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3699
5236
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3700 *ap++ = g_strdup_printf("<B>%s:</B> %s<BR>\n", _("Jabber ID"), buddy);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3701
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3702 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3703 if(strcmp(vc_tp->tag, "DESC") == 0)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3704 continue; /* special handling later */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3705 if(vc_tp->ptag == NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3706 cdata = xmlnode_get_tag_data(querynode, vc_tp->tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3707 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3708 gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3709 cdata = xmlnode_get_tag_data(querynode, tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3710 g_free(tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3711 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3712 if(cdata != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3713 if(vc_tp->url == NULL) {
5236
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3714 *ap++ = g_strdup_printf("<B>%s:</B> %s<BR>\n", _(vc_tp->label), cdata);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3715 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3716 gchar *fmt = g_strdup_printf("<B>%%s:</B> %s<BR>\n", vc_tp->url);
5236
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3717 *ap++ = g_strdup_printf(fmt, _(vc_tp->label), cdata, cdata);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3718 g_free(fmt);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3719 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3720 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3721 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3722
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3723
4450
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
3724 status = strdup_withhtml(jabber_lookup_away(gjc, buddy));
5236
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3725 *ap++ = g_strdup_printf("<B>%s:</B> %s%s%s<BR>\n",
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
3726 _("Status"),
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3727 jri ? jabber_get_state_string(jri->state) : "",
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
3728 jri && status ? ": " : "", status ? status : "");
4450
2f225b92a933 [gaim-migrate @ 4725]
Nathan Walp <nwalp@pidgin.im>
parents: 4436
diff changeset
3729 g_free(status);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3730
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3731 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3732 * "Description" handled as a special case: get a copy of the
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3733 * string and HTML-ize.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3734 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3735 if((cdata = xmlnode_get_tag_data(querynode, "DESC")) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3736 gchar *tmp = g_strdup_printf("<HR>%s<BR>", cdata);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3737 *ap++ = strdup_withhtml(tmp);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3738 g_free(tmp);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3739 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3740
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3741 *ap = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3742
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3743 final= g_strjoinv(NULL, str_arr);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3744 g_strfreev(str_arr);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3745
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3746 g_show_info_text(gc, buddy, 2, final, NULL);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3747 g_free(buddy);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3748 g_free(final);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3749 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3750
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3751 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3752 * Used by XML_Parse on parsing CDATA
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3753 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3754 static void xmlstr2xmlnode_charData(void *userdata, const char *s, int slen)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3755 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3756 xmlstr2xmlnode_parser xmlp = (xmlstr2xmlnode_parser) userdata;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3757
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3758 if (xmlp->current)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3759 xmlnode_insert_cdata(xmlp->current, s, slen);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3760 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3761
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3762 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3763 * Used by XML_Parse to start or append to an xmlnode
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3764 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3765 static void xmlstr2xmlnode_startElement(void *userdata, const char *name, const char **attribs)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3766 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3767 xmlnode x;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3768 xmlstr2xmlnode_parser xmlp = (xmlstr2xmlnode_parser) userdata;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3769
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3770 if (xmlp->current) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3771 /* Append the node to the current one */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3772 x = xmlnode_insert_tag(xmlp->current, name);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3773 xmlnode_put_expat_attribs(x, attribs);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3774
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3775 xmlp->current = x;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3776 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3777 x = xmlnode_new_tag(name);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3778 xmlnode_put_expat_attribs(x, attribs);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3779 xmlp->current = x;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3780 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3781 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3782
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3783 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3784 * Used by XML_Parse to end an xmlnode
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3785 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3786 static void xmlstr2xmlnode_endElement(void *userdata, const char *name)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3787 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3788 xmlstr2xmlnode_parser xmlp = (xmlstr2xmlnode_parser) userdata;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3789 xmlnode x;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3790
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3791 if (xmlp->current != NULL && (x = xmlnode_get_parent(xmlp->current)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3792 xmlp->current = x;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3793 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3794 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3795
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3796 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3797 * Parse an XML-encoded string into an xmlnode tree
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3798 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3799 * Caller is responsible for freeing the returned xmlnode
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3800 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3801 static xmlnode xmlstr2xmlnode(char *xmlstring)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3802 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3803 xmlstr2xmlnode_parser my_parser = g_new(xmlstr2xmlnode_parser_struct, 1);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3804 xmlnode x = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3805
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3806 my_parser->parser = XML_ParserCreate(NULL);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3807 my_parser->current = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3808
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3809 XML_SetUserData(my_parser->parser, (void *)my_parser);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3810 XML_SetElementHandler(my_parser->parser, xmlstr2xmlnode_startElement, xmlstr2xmlnode_endElement);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3811 XML_SetCharacterDataHandler(my_parser->parser, xmlstr2xmlnode_charData);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3812 XML_Parse(my_parser->parser, xmlstring, strlen(xmlstring), 0);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3813
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3814 x = my_parser->current;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3815
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3816 XML_ParserFree(my_parser->parser);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3817 g_free(my_parser);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3818
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3819 return(x);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3820 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3821
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3822 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3823 * Insert a tag node into an xmlnode tree, recursively inserting parent tag
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3824 * nodes as necessary
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3825 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3826 * Returns pointer to inserted node
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3827 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3828 * Note to hackers: this code is designed to be re-entrant (it's recursive--it
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3829 * calls itself), so don't put any "static"s in here!
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3830 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3831 static xmlnode insert_tag_to_parent_tag(xmlnode start, const char *parent_tag, const char *new_tag)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3832 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3833 xmlnode x = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3834
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3835 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3836 * If the parent tag wasn't specified, see if we can get it
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3837 * from the vCard template struct.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3838 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3839 if(parent_tag == NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3840 struct vcard_template *vc_tp = vcard_template_data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3841
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3842 while(vc_tp->label != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3843 if(strcmp(vc_tp->tag, new_tag) == 0) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3844 parent_tag = vc_tp->ptag;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3845 break;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3846 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3847 ++vc_tp;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3848 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3849 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3850
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3851 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3852 * If we have a parent tag...
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3853 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3854 if(parent_tag != NULL ) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3855 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3856 * Try to get the parent node for a tag
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3857 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3858 if((x = xmlnode_get_tag(start, parent_tag)) == NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3859 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3860 * Descend?
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3861 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3862 char *grand_parent = strcpy(g_malloc(strlen(parent_tag) + 1), parent_tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3863 char *parent;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3864
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3865 if((parent = strrchr(grand_parent, '/')) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3866 *(parent++) = '\0';
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3867 x = insert_tag_to_parent_tag(start, grand_parent, parent);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3868 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3869 x = xmlnode_insert_tag(start, grand_parent);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3870 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3871 g_free(grand_parent);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3872 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3873 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3874 * We found *something* to be the parent node.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3875 * Note: may be the "root" node!
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3876 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3877 xmlnode y;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3878 if((y = xmlnode_get_tag(x, new_tag)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3879 return(y);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3880 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3881 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3882 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3883
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3884 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3885 * insert the new tag into its parent node
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3886 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3887 return(xmlnode_insert_tag((x == NULL? start : x), new_tag));
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3888 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3889
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3890 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3891 * Find the tag name for a label
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3892 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3893 * Returns NULL on not found
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3894 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3895 static char *tag_for_label(const char *label)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3896 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3897 struct vcard_template *vc_tp = vcard_template_data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3898 char *p = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3899
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3900 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3901 if(strcmp(label, vc_tp->label) == 0) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3902 p = vc_tp->tag;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3903 break;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3904 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3905 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3906
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3907 return(p);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3908 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3909
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3910 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3911 * Send vCard info to Jabber server
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3912 */
5954
fccc33d4b8fa [gaim-migrate @ 6398]
Mark Doliner <mark@kingant.net>
parents: 5940
diff changeset
3913 static void jabber_set_info(GaimConnection *gc, const char *info)
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3914 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3915 xmlnode x, vc_node;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3916 char *id;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3917 struct jabber_data *jd = gc->proto_data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3918 gjconn gjc = jd->gjc;
5954
fccc33d4b8fa [gaim-migrate @ 6398]
Mark Doliner <mark@kingant.net>
parents: 5940
diff changeset
3919 gchar *info2;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3920
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3921 x = xmlnode_new_tag("iq");
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
3922 xmlnode_put_attrib(x, "type", "set");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3923
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3924 id = gjab_getid(gjc);
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
3925
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3926 xmlnode_put_attrib(x, "id", id);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3927
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3928 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3929 * Send only if there's actually any *information* to send
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3930 */
5954
fccc33d4b8fa [gaim-migrate @ 6398]
Mark Doliner <mark@kingant.net>
parents: 5940
diff changeset
3931 info2 = g_strdup(info);
fccc33d4b8fa [gaim-migrate @ 6398]
Mark Doliner <mark@kingant.net>
parents: 5940
diff changeset
3932 vc_node = xmlstr2xmlnode(info2);
4874
f98467b35b95 [gaim-migrate @ 5204]
Nathan Walp <nwalp@pidgin.im>
parents: 4868
diff changeset
3933
f98467b35b95 [gaim-migrate @ 5204]
Nathan Walp <nwalp@pidgin.im>
parents: 4868
diff changeset
3934 if(vc_node) {
f98467b35b95 [gaim-migrate @ 5204]
Nathan Walp <nwalp@pidgin.im>
parents: 4868
diff changeset
3935 if (xmlnode_get_name(vc_node) &&
f98467b35b95 [gaim-migrate @ 5204]
Nathan Walp <nwalp@pidgin.im>
parents: 4868
diff changeset
3936 !g_ascii_strncasecmp(xmlnode_get_name(vc_node), "vcard", 5)) {
f98467b35b95 [gaim-migrate @ 5204]
Nathan Walp <nwalp@pidgin.im>
parents: 4868
diff changeset
3937 xmlnode_insert_tag_node(x, vc_node);
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3938 gaim_debug(GAIM_DEBUG_MISC, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
3939 "jabber: vCard packet: %s\n", xmlnode2str(x));
4874
f98467b35b95 [gaim-migrate @ 5204]
Nathan Walp <nwalp@pidgin.im>
parents: 4868
diff changeset
3940 gjab_send(gjc, x);
f98467b35b95 [gaim-migrate @ 5204]
Nathan Walp <nwalp@pidgin.im>
parents: 4868
diff changeset
3941 }
f98467b35b95 [gaim-migrate @ 5204]
Nathan Walp <nwalp@pidgin.im>
parents: 4868
diff changeset
3942 xmlnode_free(vc_node);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3943 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3944
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3945 xmlnode_free(x);
5954
fccc33d4b8fa [gaim-migrate @ 6398]
Mark Doliner <mark@kingant.net>
parents: 5940
diff changeset
3946 g_free(info2);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3947 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3948
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3949 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3950 * This is the callback from the "ok clicked" for "set vCard"
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3951 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3952 * Formats GSList data into XML-encoded string and returns a pointer
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3953 * to said string.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3954 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3955 * g_free()'ing the returned string space is the responsibility of
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3956 * the caller.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3957 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3958 static gchar *jabber_format_info(MultiEntryDlg *b)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3959 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3960 xmlnode vc_node;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3961 GSList *list;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3962 MultiEntryData *med;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3963 MultiTextData *mtd;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3964 char *p;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3965
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3966 struct tag_attr *tag_attr;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3967
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3968 vc_node = xmlnode_new_tag("vCard");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3969
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3970 for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3971 xmlnode_put_attrib(vc_node, tag_attr->attr, tag_attr->value);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3972
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3973 for(list = b->multi_entry_items; list != NULL; list = list->next) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3974 med = (MultiEntryData *) list->data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3975 if(med->label != NULL && med->text != NULL && (med->text)[0] != '\0') {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3976 if((p = tag_for_label(med->label)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3977 xmlnode xp;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3978 if((xp = insert_tag_to_parent_tag(vc_node, NULL, p)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3979 xmlnode_insert_cdata(xp, med->text, -1);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3980 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3981 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3982 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3983 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3984
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3985 for(list = b->multi_text_items; list != NULL; list = list->next) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3986 mtd = (MultiTextData *) list->data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3987 if(mtd->label != NULL && mtd->text != NULL && (mtd->text)[0] != '\0') {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3988 if((p = tag_for_label(mtd->label)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3989 xmlnode xp;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3990 if((xp = insert_tag_to_parent_tag(vc_node, NULL, p)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3991 xmlnode_insert_cdata(xp, mtd->text, -1);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3992 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3993 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3994 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3995 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3996
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3997
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3998 p = g_strdup(xmlnode2str(vc_node));
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
3999 xmlnode_free(vc_node);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4000
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4001 return(p);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4002 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4003
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4004 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4005 * This gets executed by the proto action
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4006 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4007 * Creates a new MultiEntryDlg struct, gets the XML-formatted user_info
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4008 * string (if any) into GSLists for the (multi-entry) edit dialog and
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4009 * calls the set_vcard dialog.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4010 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4011 static void jabber_setup_set_info(GaimConnection *gc)
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4012 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4013 MultiEntryData *data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4014 const struct vcard_template *vc_tp;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4015 char *user_info;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4016 MultiEntryDlg *b = multi_entry_dialog_new();
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4017 char *cdata;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4018 xmlnode x_vc_data = NULL;
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4019 GaimAccount *tmp = gc->account;
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4452
diff changeset
4020 b->account = tmp;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4021
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4022
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4023 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4024 * Get existing, XML-formatted, user info
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4025 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4026 if((user_info = g_malloc(strlen(tmp->user_info) + 1)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4027 strcpy(user_info, tmp->user_info);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4028 x_vc_data = xmlstr2xmlnode(user_info);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4029 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4030
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4031 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4032 * Set up GSLists for edit with labels from "template," data from user info
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4033 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4034 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4035 if((vc_tp->label)[0] == '\0')
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4036 continue;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4037 if(vc_tp->ptag == NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4038 cdata = xmlnode_get_tag_data(x_vc_data, vc_tp->tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4039 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4040 gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4041 cdata = xmlnode_get_tag_data(x_vc_data, tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4042 g_free(tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4043 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4044 if(strcmp(vc_tp->tag, "DESC") == 0) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4045 multi_text_list_update(&(b->multi_text_items),
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4046 vc_tp->label, cdata, TRUE);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4047 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4048 data = multi_entry_list_update(&(b->multi_entry_items),
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4049 vc_tp->label, cdata, TRUE);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4050 data->visible = vc_tp->visible;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4051 data->editable = vc_tp->editable;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4052 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4053 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4054
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4055
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4056 if(x_vc_data != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4057 xmlnode_free(x_vc_data);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4058 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4059 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4060 * Early Beta versions had a different user_info storage format--let's
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4061 * see if that works.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4062 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4063 * This goes away RSN.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4064 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4065 const char *record_separator = "<BR>";
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4066 const char *field_separator = ": ";
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4067 gchar **str_list, **str_list_ptr, **str_list2;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4068
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4069 if((str_list = g_strsplit(user_info, record_separator, 0)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4070 for(str_list_ptr = str_list; *str_list_ptr != NULL; ++str_list_ptr) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4071 str_list2 = g_strsplit(*str_list_ptr, field_separator, 2);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4072 if(str_list2[0] != NULL && str_list2[1] != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4073 g_strstrip(str_list2[0]);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4074 g_strstrip(str_list2[1]);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4075 /* this is ugly--so far */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4076 if(strcmp(str_list2[0], "Description") == 0) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4077 multi_text_list_update(&(b->multi_text_items),
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4078 str_list2[0], str_list2[1], FALSE);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4079 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4080 multi_entry_list_update(&(b->multi_entry_items),
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4081 str_list2[0], str_list2[1], FALSE);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4082 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4083 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4084 g_strfreev(str_list2);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4085 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4086 g_strfreev(str_list);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4087 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4088 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4089
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4090 if(user_info != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4091 g_free(user_info);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4092 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4093
2975
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
4094 b->title = _("Gaim - Edit Jabber vCard");
4074
3ccbdf8e7f8d [gaim-migrate @ 4289]
Sean Egan <seanegan@gmail.com>
parents: 4059
diff changeset
4095 b->role = "set_info";
5236
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
4096 b->instructions->text = g_strdup(_(multi_entry_instructions));
0d4b8ca97c17 [gaim-migrate @ 5606]
Luke Schierer <lschiere@pidgin.im>
parents: 5234
diff changeset
4097 b->entries_title = g_strdup(_(entries_title));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4098
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4099 b->custom = (void *) jabber_format_info;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4100
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4101 show_set_vcard(b);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4102 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4103
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4104 /*---------------------------------------*/
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4105 /* End Jabber "set info" (vCard) support */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4106 /*---------------------------------------*/
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4107
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4108 /*----------------------------------------*/
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4109 /* Jabber "user registration" support */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4110 /*----------------------------------------*/
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4111
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4112 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4113 * Three of the following four functions duplicate much of what
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4114 * exists elsewhere:
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4115 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4116 * jabber_handleregresp()
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4117 * gjab_reqreg()
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4118 * jabber_handle_registration_state()
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4119 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4120 * It may be that an additional flag could be added to one of
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4121 * the "local" structs and the duplicated code modified to
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4122 * account for it--thus eliminating the duplication. Then again:
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4123 * doing it the way it is may be much cleaner.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4124 *
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4125 * TBD: Code to support requesting additional information server
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4126 * wants at registration--incl. dialog.
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4127 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4128
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4129 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4130 * Like jabber_handlepacket(), only different
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4131 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4132 static void jabber_handleregresp(gjconn gjc, jpacket p)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4133 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4134 if (jpacket_subtype(p) == JPACKET__RESULT) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4135 xmlnode querynode;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4136
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4137 if((querynode = xmlnode_get_tag(p->x, "query")) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4138 char *xmlns;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4139
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4140 /* we damn well *better* have this! */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4141 if((xmlns = xmlnode_get_attrib(querynode, "xmlns")) != NULL &&
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4142 strcmp(xmlns, NS_REGISTER) == 0) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4143
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4144 char *tag;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4145 xmlnode child = xmlnode_get_firstchild(querynode);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4146
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4147 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4148 "got registration requirments response!\n");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4149
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4150 while(child != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4151 if((tag = xmlnode_get_name(child)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4152 char *data;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4153
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4154 fprintf(stderr, "DBG: got node: \"%s\"\n", tag);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4155 fflush(stderr);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4156
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4157 if((data = xmlnode_get_data(child)) != NULL) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4158 fprintf(stderr, "DBG: got data: \"%s\"\n", data);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4159 fflush(stderr);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4160 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4161 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4162 child = xmlnode_get_nextsibling(child);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4163 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4164 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4165 } else {
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4166 gaim_debug(GAIM_DEBUG_INFO, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4167 "registration successful!\n");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4168
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4169 gaim_connection_notice(GJ_GC(gjc), _("Server Registration successful!"));
5578
847ad796326d [gaim-migrate @ 5982]
Christian Hammond <chipx86@chipx86.com>
parents: 5572
diff changeset
4170 gaim_connection_destroy(GJ_GC(gjc));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4171 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4172
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4173 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4174 xmlnode xerr;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4175 char *errmsg = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4176 int errcode = 0;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4177
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4178 gaim_debug(GAIM_DEBUG_ERROR, "jabber", "registration failed\n");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4179 xerr = xmlnode_get_tag(p->x, "error");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4180 if (xerr) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4181 char msg[BUF_LONG];
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4182 errmsg = xmlnode_get_data(xerr);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4183 if (xmlnode_get_attrib(xerr, "code")) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4184 errcode = atoi(xmlnode_get_attrib(xerr, "code"));
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4185 g_snprintf(msg, sizeof(msg), "Error %d: %s", errcode, errmsg);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4186 } else
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4187 g_snprintf(msg, sizeof(msg), "%s", errmsg);
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4188 gaim_connection_error(GJ_GC(gjc), msg);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4189 } else {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4190 gaim_connection_error(GJ_GC(gjc), _("Unknown registration error"));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4191 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4192 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4193 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4194
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4195 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4196 * Like gjab_reqauth(), only different
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4197 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4198 static void gjab_reqreg(gjconn gjc)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4199 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4200 xmlnode x, y, z;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4201 char *user;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4202
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4203 if (!gjc)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4204 return;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4205
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4206 x = jutil_iqnew(JPACKET__SET, NS_REGISTER);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4207 y = xmlnode_get_tag(x, "query");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4208
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4209 user = gjc->user->user;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4210
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4211 if (user) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4212 z = xmlnode_insert_tag(y, "username");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4213 xmlnode_insert_cdata(z, user, -1);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4214 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4215 z = xmlnode_insert_tag(y, "password");
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4216 xmlnode_insert_cdata(z, gjc->pass, -1);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4217
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4218 gaim_debug(GAIM_DEBUG_MISC, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4219 "jabber: registration packet: %s\n", xmlnode2str(x));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4220 gjab_send(gjc, x);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4221 xmlnode_free(x);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4222 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4223
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4224 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4225 * Like jabber_handlestate(), only different
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4226 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4227 static void jabber_handle_registration_state(gjconn gjc, int state)
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4228 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4229 switch (state) {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4230 case JCONN_STATE_OFF:
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
4231 if(gjc->was_connected) {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4232 gaim_connection_error(GJ_GC(gjc), _("Connection lost"));
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
4233 } else {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4234 gaim_connection_error(GJ_GC(gjc), _("Unable to connect"));
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
4235 }
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4236 break;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4237 case JCONN_STATE_CONNECTED:
3074
793fb2e9d53b [gaim-migrate @ 3088]
Sean Egan <seanegan@gmail.com>
parents: 3059
diff changeset
4238 gjc->was_connected = 1;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4239 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4240 * TBD?
2975
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
4241 set_login_progress(GJ_GC(gjc), 2, _("Connected"));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4242 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4243 break;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4244 case JCONN_STATE_ON:
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4245 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4246 * TBD?
2975
626729653436 [gaim-migrate @ 2988]
Rob Flynn <gaim@robflynn.com>
parents: 2956
diff changeset
4247 set_login_progress(GJ_GC(gjc), 3, _("Requesting Authentication Method"));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4248 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4249 gjab_reqreg(gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4250 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4251 * TBD: A work-in-progress
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4252 gjab_reqregreqs(gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4253 */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4254 break;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4255 default:
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4256 gaim_debug(GAIM_DEBUG_MISC, "jabber", "state change: %d\n", state);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4257 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4258 return;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4259 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4260
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4261 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4262 * Like jabber_login(), only different
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4263 */
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4264 void jabber_register_user(GaimAccount *account)
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4265 {
6003
0ca618645cec [gaim-migrate @ 6451]
Nathan Walp <nwalp@pidgin.im>
parents: 5994
diff changeset
4266 GaimConnection *gc = gaim_connection_new(account);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4267 struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1);
4917
c0c6efda8151 [gaim-migrate @ 5251]
Sean Egan <seanegan@gmail.com>
parents: 4916
diff changeset
4268 char *loginname = create_valid_jid(account->username, DEFAULT_SERVER, "Gaim");
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4269
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4270 /*
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4271 * These do nothing during registration
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4272 */
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
4273 jd->buddies = NULL;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4274 jd->chats = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4275
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4452
diff changeset
4276 if ((jd->gjc = gjab_new(loginname, account->password, gc)) == NULL) {
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4277 g_free(loginname);
5223
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4278 gaim_debug(GAIM_DEBUG_ERROR, "jabber",
e2e5bc3ca705 [gaim-migrate @ 5593]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
4279 "unable to connect (jab_new failed)\n");
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4280 gaim_connection_error(gc, _("Unable to connect"));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4281 } else {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4282 gjab_state_handler(jd->gjc, jabber_handle_registration_state);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4283 gjab_packet_handler(jd->gjc, jabber_handleregresp);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4284 jd->gjc->queries = NULL;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4285 gjab_start(jd->gjc);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4286 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4287
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4288 g_free(loginname);
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4289 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4290
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4291 /*----------------------------------------*/
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4292 /* End Jabber "user registration" support */
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4293 /*----------------------------------------*/
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4294
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
4295 static GList *jabber_actions(GaimConnection *gc)
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4296 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4297 GList *m = NULL;
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4298 struct proto_actions_menu *pam;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4299
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4300 pam = g_new0(struct proto_actions_menu, 1);
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4301 pam->label = _("Set User Info");
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4302 pam->callback = jabber_setup_set_info;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4303 pam->gc = gc;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4304 m = g_list_append(m, pam);
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4305
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4306 /*
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4307 pam = g_new0(struct proto_actions_menu, 1);
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4308 pam->label = _("Set Dir Info");
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4309 pam->callback = show_set_dir;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4310 pam->gc = gc;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4311 m = g_list_append(m, pam);
3257
4c28751180f9 [gaim-migrate @ 3275]
Jim Seymour <jseymour>
parents: 3254
diff changeset
4312 */
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4313
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4314 pam = g_new0(struct proto_actions_menu, 1);
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4315 pam->label = _("Change Password");
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4316 pam->callback = show_change_passwd;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4317 pam->gc = gc;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
4318 m = g_list_append(m, pam);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4319
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4320 return m;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4321 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
4322
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4323 static GaimPluginProtocolInfo prpl_info =
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4324 {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4325 GAIM_PROTO_JABBER,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4326 OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_CHAT_TOPIC,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4327 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4328 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4329 jabber_list_icon,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4330 jabber_list_emblems,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4331 jabber_status_text,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4332 jabber_tooltip_text,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4333 jabber_away_states,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4334 jabber_actions,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4335 jabber_buddy_menu,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4336 jabber_chat_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4337 jabber_login,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4338 jabber_close,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4339 jabber_send_im,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4340 jabber_set_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4341 jabber_send_typing,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4342 jabber_get_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4343 jabber_set_away,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4344 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4345 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4346 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4347 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4348 jabber_set_idle,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4349 jabber_change_passwd,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4350 jabber_add_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4351 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4352 jabber_remove_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4353 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4354 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4355 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4356 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4357 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4358 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4359 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4360 jabber_join_chat,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4361 jabber_chat_invite,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4362 jabber_chat_leave,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4363 jabber_chat_whisper,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4364 jabber_chat_send,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4365 jabber_keepalive,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4366 jabber_register_user,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4367 jabber_get_cb_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4368 jabber_get_cb_away_msg,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4369 jabber_alias_buddy,
5957
c5c3ddac1c89 [gaim-migrate @ 6401]
Nathan Walp <nwalp@pidgin.im>
parents: 5954
diff changeset
4370 jabber_group_change,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4371 jabber_rename_group,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4372 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4373 jabber_convo_closed,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4374 jabber_normalize
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4375 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4376
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4377 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4378 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4379 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4380 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4381 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4382 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4383 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4384 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4385
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4386 "prpl-jabber", /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4387 "Jabber", /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4388 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4389 /** summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4390 N_("Jabber Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4391 /** description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4392 N_("Jabber Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4393 NULL, /**< author */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4394 WEBSITE, /**< homepage */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4395
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4396 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4397 NULL, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4398 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4399
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4400 NULL, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4401 &prpl_info /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4402 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4403
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4404 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5894
diff changeset
4405 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4406 {
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4407 GaimAccountUserSplit *split;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4408 GaimAccountOption *option;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4409
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4410 /* Splits */
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4411 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@');
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4412 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4413
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4414 split = gaim_account_user_split_new(_("Resource"), "Gaim", '/');
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4415 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4416
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4417 /* Account Options */
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4418 option = gaim_account_option_int_new(_("Port"), "port", DEFAULT_PORT);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4419 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4420 option);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4421
5685
43ea75092684 [gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
4422 option = gaim_account_option_string_new(_("Connect server"),
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4423 "connect_server", NULL);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4424 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
4425 option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4426
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
4427 my_protocol = plugin;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4428 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4429
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5894
diff changeset
4430 GAIM_INIT_PLUGIN(jabber, init_plugin, info);