Mercurial > hg
annotate mcabber/src/jab_iq.c @ 1593:06fdfff29175 0.9.10
Ready for release 0.9.10
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 06 Oct 2009 21:32:30 +0200 |
parents | 8e52ce94eee0 |
children |
rev | line source |
---|---|
29 | 1 /* |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
2 * jab_iq.c -- Jabber protocol IQ-related fonctions |
393 | 3 * |
1414 | 4 * Copyright (C) 2005-2008 Mikael Berthe <mikael@lilotux.net> |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
5 * Some parts initially came from the centericq project: |
29 | 6 * Copyright (C) 2002-2005 by Konstantin Klyagin <konst@konst.org.ua> |
1361 | 7 * Some small parts come from the Pidgin project <http://pidgin.im/> |
29 | 8 * |
9 * This program is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or (at | |
12 * your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 * USA | |
23 */ | |
24 | |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
25 #include <sys/utsname.h> |
603 | 26 #include <glib.h> |
27 | |
29 | 28 #include "jabglue.h" |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
29 #include "jab_priv.h" |
81 | 30 #include "roster.h" |
29 | 31 #include "utils.h" |
603 | 32 #include "screen.h" |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
33 #include "settings.h" |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
34 #include "hbuf.h" |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
35 #include "commands.h" |
1353
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
36 #include "hooks.h" |
164 | 37 |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
38 #ifdef ENABLE_HGCSET |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
39 # include "hgcset.h" |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
40 #endif |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
41 |
683 | 42 |
1008
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
43 // Bookmarks for IQ:private storage |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
44 xmlnode bookmarks; |
1016 | 45 // Roster notes for IQ:private storage |
46 xmlnode rosternotes; | |
1008
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
47 |
683 | 48 static GSList *iqs_list; |
49 | |
1254
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
50 time_t iqlast; // last message/status change time |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
51 |
1006 | 52 // Enum for vCard attributes |
53 enum vcard_attr { | |
54 vcard_home = 1<<0, | |
55 vcard_work = 1<<1, | |
56 vcard_postal = 1<<2, | |
57 vcard_voice = 1<<3, | |
58 vcard_fax = 1<<4, | |
59 vcard_cell = 1<<5, | |
60 vcard_inet = 1<<6, | |
61 vcard_pref = 1<<7, | |
62 }; | |
683 | 63 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
64 static void handle_iq_command_set_status(jconn conn, char *from, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
65 const char *id, xmlnode xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
66 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
67 static void handle_iq_command_leave_groupchats(jconn conn, char *from, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
68 const char *id, xmlnode xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
69 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
70 typedef void (*adhoc_command_callback)(jconn, char*, const char*, xmlnode); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
71 |
1558
3df441efb7c2
Fix gcc warnings related to inline/static uses
Mikael Berthe <mikael@lilotux.net>
parents:
1498
diff
changeset
|
72 inline double seconds_since_last_use(void); |
3df441efb7c2
Fix gcc warnings related to inline/static uses
Mikael Berthe <mikael@lilotux.net>
parents:
1498
diff
changeset
|
73 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
74 struct adhoc_command { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
75 char *name; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
76 char *description; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
77 bool only_for_self; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
78 adhoc_command_callback callback; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
79 }; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
80 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
81 const struct adhoc_command adhoc_command_list[] = { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
82 { "http://jabber.org/protocol/rc#set-status", |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
83 "Change client status", |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
84 1, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
85 &handle_iq_command_set_status }, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
86 { "http://jabber.org/protocol/rc#leave-groupchats", |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
87 "Leave groupchat(s)", |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
88 1, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
89 &handle_iq_command_leave_groupchats }, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
90 { NULL, NULL, 0, NULL }, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
91 }; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
92 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
93 struct adhoc_status { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
94 char *name; // the name used by adhoc |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
95 char *description; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
96 char *status; // the string, used by setstus |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
97 }; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
98 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
99 const struct adhoc_status adhoc_status_list[] = { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
100 {"online", "Online", "avail"}, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
101 {"chat", "Chat", "free"}, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
102 {"away", "Away", "away"}, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
103 {"xd", "Extended away", "notavail"}, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
104 {"dnd", "Do not disturb", "dnd"}, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
105 {"invisible", "Invisible", "invisible"}, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
106 {"offline", "Offline", "offline"}, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
107 {NULL, NULL, NULL}, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
108 }; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
109 |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
110 // entity_version() |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
111 // Return a static version string for Entity Capabilities. |
1218
ab5de2ed2b7e
Simplify entity_version()
Mikael Berthe <mikael@lilotux.net>
parents:
1217
diff
changeset
|
112 // It should be specific to the client version, please change the id |
ab5de2ed2b7e
Simplify entity_version()
Mikael Berthe <mikael@lilotux.net>
parents:
1217
diff
changeset
|
113 // if you alter mcabber's disco support (or add something to the version |
ab5de2ed2b7e
Simplify entity_version()
Mikael Berthe <mikael@lilotux.net>
parents:
1217
diff
changeset
|
114 // number) so that it doesn't conflict with the official client. |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
115 const char *entity_version(void) |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
116 { |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
117 static char *ver; |
1334
f8cfa22cedc2
Ready for release 0.9.4
Mikael Berthe <mikael@lilotux.net>
parents:
1333
diff
changeset
|
118 const char *PVERSION = PACKAGE_VERSION; // "+xxx"; |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
119 |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
120 if (ver) |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
121 return ver; |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
122 |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
123 #ifdef HGCSET |
1255
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
124 ver = g_strdup_printf("%s-%s", PVERSION, HGCSET); |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
125 #else |
1255
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
126 ver = g_strdup(PVERSION); |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
127 #endif |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
128 |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
129 return ver; |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
130 } |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
131 |
683 | 132 // iqs_new(type, namespace, prefix, timeout) |
133 // Create a query (GET, SET) IQ structure. This function should not be used | |
134 // for RESULT packets. | |
1058 | 135 eviqs *iqs_new(guint8 type, const char *ns, const char *prefix, time_t tmout) |
683 | 136 { |
137 static guint iqs_idn; | |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
138 eviqs *new_iqs; |
683 | 139 time_t now_t; |
140 | |
141 iqs_idn++; | |
142 | |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
143 new_iqs = g_new0(eviqs, 1); |
683 | 144 time(&now_t); |
145 new_iqs->ts_create = now_t; | |
1058 | 146 if (tmout) |
147 new_iqs->ts_expire = now_t + tmout; | |
683 | 148 new_iqs->type = type; |
149 new_iqs->xmldata = jutil_iqnew(type, (char*)ns); | |
150 if (prefix) | |
687
426145046b93
Minor format change in IQ id string
Mikael Berthe <mikael@lilotux.net>
parents:
686
diff
changeset
|
151 new_iqs->id = g_strdup_printf("%s_%d", prefix, iqs_idn); |
683 | 152 else |
153 new_iqs->id = g_strdup_printf("%d", iqs_idn); | |
154 xmlnode_put_attrib(new_iqs->xmldata, "id", new_iqs->id); | |
155 | |
156 iqs_list = g_slist_append(iqs_list, new_iqs); | |
157 return new_iqs; | |
158 } | |
159 | |
160 int iqs_del(const char *iqid) | |
161 { | |
162 GSList *p; | |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
163 eviqs *i; |
683 | 164 |
165 if (!iqid) return 1; | |
166 | |
167 for (p = iqs_list; p; p = g_slist_next(p)) { | |
168 i = p->data; | |
169 if (!strcmp(iqid, i->id)) | |
170 break; | |
171 } | |
172 if (p) { | |
173 g_free(i->id); | |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
174 xmlnode_free(i->xmldata); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
175 g_free(i->data); |
683 | 176 g_free(i); |
177 iqs_list = g_slist_remove(iqs_list, p->data); | |
178 return 0; // Ok, deleted | |
179 } | |
180 return -1; // Not found | |
181 } | |
182 | |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
183 static eviqs *iqs_find(const char *iqid) |
683 | 184 { |
185 GSList *p; | |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
186 eviqs *i; |
683 | 187 |
188 if (!iqid) return NULL; | |
189 | |
190 for (p = iqs_list; p; p = g_slist_next(p)) { | |
191 i = p->data; | |
192 if (!strcmp(iqid, i->id)) | |
193 return i; | |
194 } | |
195 return NULL; | |
196 } | |
197 | |
698
60522cf6d325
Propagate context to IQ callback functions
Mikael Berthe <mikael@lilotux.net>
parents:
692
diff
changeset
|
198 // iqs_callback(iqid, xml_result, iqcontext) |
683 | 199 // Callback processing for the iqid message. |
200 // If we've received an answer, xml_result should point to the xmldata packet. | |
201 // If this is a timeout, xml_result should be NULL. | |
202 // Return 0 in case of success, -1 if the iqid hasn't been found. | |
698
60522cf6d325
Propagate context to IQ callback functions
Mikael Berthe <mikael@lilotux.net>
parents:
692
diff
changeset
|
203 int iqs_callback(const char *iqid, xmlnode xml_result, guint iqcontext) |
683 | 204 { |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
205 eviqs *i; |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
206 int retval = 0; |
683 | 207 |
208 i = iqs_find(iqid); | |
209 if (!i) return -1; | |
210 | |
211 // IQ processing | |
212 // Note: If xml_result is NULL, this is a timeout | |
213 if (i->callback) | |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
214 retval = (*i->callback)(i, xml_result, iqcontext); |
683 | 215 |
216 iqs_del(iqid); | |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
217 return retval; |
683 | 218 } |
219 | |
705
603b43e4f56a
Fix a bug in iqs_check_timeout()
Mikael Berthe <mikael@lilotux.net>
parents:
704
diff
changeset
|
220 void iqs_check_timeout(time_t now_t) |
683 | 221 { |
222 GSList *p; | |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
223 eviqs *i; |
683 | 224 |
705
603b43e4f56a
Fix a bug in iqs_check_timeout()
Mikael Berthe <mikael@lilotux.net>
parents:
704
diff
changeset
|
225 p = iqs_list; |
603b43e4f56a
Fix a bug in iqs_check_timeout()
Mikael Berthe <mikael@lilotux.net>
parents:
704
diff
changeset
|
226 while (p) { |
603b43e4f56a
Fix a bug in iqs_check_timeout()
Mikael Berthe <mikael@lilotux.net>
parents:
704
diff
changeset
|
227 i = p->data; |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
228 // We must get next IQ eviqs element now because the current one |
705
603b43e4f56a
Fix a bug in iqs_check_timeout()
Mikael Berthe <mikael@lilotux.net>
parents:
704
diff
changeset
|
229 // could be freed. |
603b43e4f56a
Fix a bug in iqs_check_timeout()
Mikael Berthe <mikael@lilotux.net>
parents:
704
diff
changeset
|
230 p = g_slist_next(p); |
683 | 231 |
965
1bdf0f1b16c0
Use U suffix for unsigned defines
Mikael Berthe <mikael@lilotux.net>
parents:
959
diff
changeset
|
232 if ((!i->ts_expire && now_t > i->ts_create + (time_t)IQS_MAX_TIMEOUT) || |
683 | 233 (i->ts_expire && now_t > i->ts_expire)) { |
698
60522cf6d325
Propagate context to IQ callback functions
Mikael Berthe <mikael@lilotux.net>
parents:
692
diff
changeset
|
234 iqs_callback(i->id, NULL, IQS_CONTEXT_TIMEOUT); |
683 | 235 } |
236 } | |
237 } | |
238 | |
689
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
239 void jb_iqs_display_list(void) |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
240 { |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
241 GSList *p; |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
242 eviqs *i; |
689
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
243 |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
244 scr_LogPrint(LPRINT_LOGNORM, "IQ list:"); |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
245 for (p = iqs_list; p; p = g_slist_next(p)) { |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
246 i = p->data; |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
247 scr_LogPrint(LPRINT_LOGNORM, "Id [%s]", i->id); |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
248 } |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
249 scr_LogPrint(LPRINT_LOGNORM, "End of IQ list."); |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
250 } |
281aab5aef50
Introduce jb_iqs_display_list() helper function for debugging
Mikael Berthe <mikael@lilotux.net>
parents:
688
diff
changeset
|
251 |
606
0b4ed231ebc2
Code cleanup + remove deprecated Agents list IQ request
Mikael Berthe <mikael@lilotux.net>
parents:
605
diff
changeset
|
252 static void handle_iq_roster(xmlnode x) |
29 | 253 { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
254 xmlnode y; |
1058 | 255 const char *fjid, *name, *group, *sub, *ask; |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
256 char *cleanalias; |
603 | 257 enum subscr esub; |
258 int need_refresh = FALSE; | |
613
a6b8b373e4de
Try to guess if a roster item is an agent
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
259 guint roster_type; |
29 | 260 |
261 for (y = xmlnode_get_tag(x, "item"); y; y = xmlnode_get_nextsibling(y)) { | |
1348
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
262 char *name_tmp = NULL; |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
263 |
1058 | 264 fjid = xmlnode_get_attrib(y, "jid"); |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
265 name = xmlnode_get_attrib(y, "name"); |
603 | 266 sub = xmlnode_get_attrib(y, "subscription"); |
605
2a4fefb98511
Set the subscription pending flag
Mikael Berthe <mikael@lilotux.net>
parents:
603
diff
changeset
|
267 ask = xmlnode_get_attrib(y, "ask"); |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
268 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
269 group = xmlnode_get_tag_data(y, "group"); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
270 |
1058 | 271 if (!fjid) |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
272 continue; |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
273 |
1058 | 274 cleanalias = jidtodisp(fjid); |
29 | 275 |
603 | 276 esub = sub_none; |
277 if (sub) { | |
278 if (!strcmp(sub, "to")) esub = sub_to; | |
279 else if (!strcmp(sub, "from")) esub = sub_from; | |
280 else if (!strcmp(sub, "both")) esub = sub_both; | |
281 else if (!strcmp(sub, "remove")) esub = sub_remove; | |
282 } | |
283 | |
284 if (esub == sub_remove) { | |
285 roster_del_user(cleanalias); | |
286 scr_LogPrint(LPRINT_LOGNORM, "Buddy <%s> has been removed " | |
287 "from the roster", cleanalias); | |
288 g_free(cleanalias); | |
289 need_refresh = TRUE; | |
290 continue; | |
291 } | |
292 | |
605
2a4fefb98511
Set the subscription pending flag
Mikael Berthe <mikael@lilotux.net>
parents:
603
diff
changeset
|
293 if (ask && !strcmp(ask, "subscribe")) |
2a4fefb98511
Set the subscription pending flag
Mikael Berthe <mikael@lilotux.net>
parents:
603
diff
changeset
|
294 esub |= sub_pending; |
2a4fefb98511
Set the subscription pending flag
Mikael Berthe <mikael@lilotux.net>
parents:
603
diff
changeset
|
295 |
1348
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
296 if (!name) { |
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
297 if (!settings_opt_get_int("roster_hide_domain")) { |
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
298 name = cleanalias; |
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
299 } else { |
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
300 char *p; |
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
301 name = name_tmp = g_strdup(cleanalias); |
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
302 p = strchr(name_tmp, JID_DOMAIN_SEPARATOR); |
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
303 if (p) *p = '\0'; |
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
304 } |
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
305 } |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
306 |
977
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
965
diff
changeset
|
307 // Tricky... :-\ My guess is that if there is no JID_DOMAIN_SEPARATOR, |
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
965
diff
changeset
|
308 // this is an agent. |
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
965
diff
changeset
|
309 if (strchr(cleanalias, JID_DOMAIN_SEPARATOR)) |
613
a6b8b373e4de
Try to guess if a roster item is an agent
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
310 roster_type = ROSTER_TYPE_USER; |
a6b8b373e4de
Try to guess if a roster item is an agent
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
311 else |
a6b8b373e4de
Try to guess if a roster item is an agent
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
312 roster_type = ROSTER_TYPE_AGENT; |
a6b8b373e4de
Try to guess if a roster item is an agent
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
313 |
1355 | 314 roster_add_user(cleanalias, name, group, roster_type, esub, 1); |
603 | 315 |
1348
26d1dd2c948f
Add option 'roster_hide_domain'
Mikael Berthe <mikael@lilotux.net>
parents:
1340
diff
changeset
|
316 g_free(name_tmp); |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
317 g_free(cleanalias); |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
318 } |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
319 |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
320 buddylist_build(); |
603 | 321 update_roster = TRUE; |
322 if (need_refresh) | |
959
8bf36cef8aa6
Do not enter chat mode after command "/del"
Mikael Berthe <mikael@lilotux.net>
parents:
871
diff
changeset
|
323 scr_UpdateBuddyWindow(); |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
324 } |
29 | 325 |
1353
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
326 // This callback is reached when mcabber receives the first roster update |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
327 // after the connection. |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
328 static int iqscallback_gotroster(eviqs *iqp, xmlnode xml_result, guint iqcontext) |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
329 { |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
330 xmlnode x; |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
331 char *ns; |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
332 |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
333 // Leave now if we cannot process xml_result |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
334 if (!xml_result || iqcontext) return -1; |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
335 |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
336 // Only execute the hook if the roster has been successfully retrieved |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
337 if (iqcontext != IQS_CONTEXT_RESULT) |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
338 return 0; |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
339 |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
340 x = xmlnode_get_tag(xml_result, "query"); |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
341 if (!x) |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
342 return -1; |
1365 | 343 |
1353
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
344 ns = xmlnode_get_attrib(x, "xmlns"); |
1365 | 345 if (ns && !strcmp(ns, NS_ROSTER)) |
1353
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
346 handle_iq_roster(x); |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
347 |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
348 // Post-login stuff |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
349 jb_setprevstatus(); |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
350 hook_execute_internal("hook-post-connect"); |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
351 |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
352 return 0; |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
353 } |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
354 |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
355 static void request_roster(void) |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
356 { |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
357 eviqs *iqn = iqs_new(JPACKET__GET, NS_ROSTER, "Roster", IQS_DEFAULT_TIMEOUT); |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
358 iqn->callback = &iqscallback_gotroster; |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
359 jab_send(jc, iqn->xmldata); |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
360 } |
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
361 |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
362 static int iqscallback_version(eviqs *iqp, xmlnode xml_result, guint iqcontext) |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
363 { |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
364 xmlnode ansqry; |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
365 char *p; |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
366 char *bjid; |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
367 char *buf; |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
368 |
698
60522cf6d325
Propagate context to IQ callback functions
Mikael Berthe <mikael@lilotux.net>
parents:
692
diff
changeset
|
369 // Leave now if we cannot process xml_result |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
370 if (!xml_result || iqcontext) return -1; |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
371 |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
372 ansqry = xmlnode_get_tag(xml_result, "query"); |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
373 if (!ansqry) { |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
374 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:version result!"); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
375 return 0; |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
376 } |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
377 // Display IQ result sender... |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
378 p = xmlnode_get_attrib(xml_result, "from"); |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
379 if (!p) { |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
380 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:version result (no sender name)."); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
381 return 0; |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
382 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
746
diff
changeset
|
383 bjid = p; |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
384 |
782
19121d9f4aa2
Nicer message when receiving IQ result packet
Mikael Berthe <mikael@lilotux.net>
parents:
776
diff
changeset
|
385 buf = g_strdup_printf("Received IQ:version result from <%s>", bjid); |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
386 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
387 |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
388 // bjid should now really be the "bare JID", let's strip the resource |
977
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
965
diff
changeset
|
389 p = strchr(bjid, JID_RESOURCE_SEPARATOR); |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
390 if (p) *p = '\0'; |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
391 |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1283
diff
changeset
|
392 scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO, 0); |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
393 g_free(buf); |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
394 |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
395 // Get result data... |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
396 p = xmlnode_get_tag_data(ansqry, "name"); |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
397 if (p) { |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
398 buf = g_strdup_printf("Name: %s", p); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
399 scr_WriteIncomingMessage(bjid, buf, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
400 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
401 g_free(buf); |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
402 } |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
403 p = xmlnode_get_tag_data(ansqry, "version"); |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
404 if (p) { |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
405 buf = g_strdup_printf("Version: %s", p); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
406 scr_WriteIncomingMessage(bjid, buf, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
407 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
408 g_free(buf); |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
409 } |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
410 p = xmlnode_get_tag_data(ansqry, "os"); |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
411 if (p) { |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
412 buf = g_strdup_printf("OS: %s", p); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
413 scr_WriteIncomingMessage(bjid, buf, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
414 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
415 g_free(buf); |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
416 } |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
417 return 0; |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
418 } |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
419 |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
420 void request_version(const char *fulljid) |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
421 { |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
422 eviqs *iqn; |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
423 |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
424 iqn = iqs_new(JPACKET__GET, NS_VERSION, "version", IQS_DEFAULT_TIMEOUT); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
746
diff
changeset
|
425 xmlnode_put_attrib(iqn->xmldata, "to", fulljid); |
690
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
426 iqn->callback = &iqscallback_version; |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
427 jab_send(jc, iqn->xmldata); |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
428 } |
3e965a1186c7
Implement IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
689
diff
changeset
|
429 |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
430 static int iqscallback_time(eviqs *iqp, xmlnode xml_result, guint iqcontext) |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
431 { |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
432 xmlnode ansqry; |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
433 char *p; |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
434 char *bjid; |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
435 char *buf; |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
436 |
698
60522cf6d325
Propagate context to IQ callback functions
Mikael Berthe <mikael@lilotux.net>
parents:
692
diff
changeset
|
437 // Leave now if we cannot process xml_result |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
438 if (!xml_result || iqcontext) return -1; |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
439 |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
440 ansqry = xmlnode_get_tag(xml_result, "query"); |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
441 if (!ansqry) { |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
442 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:time result!"); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
443 return 0; |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
444 } |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
445 // Display IQ result sender... |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
446 p = xmlnode_get_attrib(xml_result, "from"); |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
447 if (!p) { |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
448 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:time result (no sender name)."); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
449 return 0; |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
450 } |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
746
diff
changeset
|
451 bjid = p; |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
452 |
782
19121d9f4aa2
Nicer message when receiving IQ result packet
Mikael Berthe <mikael@lilotux.net>
parents:
776
diff
changeset
|
453 buf = g_strdup_printf("Received IQ:time result from <%s>", bjid); |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
454 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
455 |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
456 // bjid should now really be the "bare JID", let's strip the resource |
977
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
965
diff
changeset
|
457 p = strchr(bjid, JID_RESOURCE_SEPARATOR); |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
458 if (p) *p = '\0'; |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
459 |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1283
diff
changeset
|
460 scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO, 0); |
704
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
461 g_free(buf); |
4118a66f2c02
Display IQ results (time, version) in the chat window
Mikael Berthe <mikael@lilotux.net>
parents:
703
diff
changeset
|
462 |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
463 // Get result data... |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
464 p = xmlnode_get_tag_data(ansqry, "utc"); |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
465 if (p) { |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
466 buf = g_strdup_printf("UTC: %s", p); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
467 scr_WriteIncomingMessage(bjid, buf, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
468 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
469 g_free(buf); |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
470 } |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
471 p = xmlnode_get_tag_data(ansqry, "tz"); |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
472 if (p) { |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
473 buf = g_strdup_printf("TZ: %s", p); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
474 scr_WriteIncomingMessage(bjid, buf, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
475 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
476 g_free(buf); |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
477 } |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
478 p = xmlnode_get_tag_data(ansqry, "display"); |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
479 if (p) { |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
480 buf = g_strdup_printf("Time: %s", p); |
1333
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
481 scr_WriteIncomingMessage(bjid, buf, |
e30a9d907105
Minor coding style adjustments
Mikael Berthe <mikael@lilotux.net>
parents:
1310
diff
changeset
|
482 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1030
923cf5a92b44
[BP-dd9e7eb5f8a8] Remove old UTF-8 conversions
Mikael Berthe <mikael@lilotux.net>
parents:
965
diff
changeset
|
483 g_free(buf); |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
484 } |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
485 return 0; |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
486 } |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
487 |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
488 void request_time(const char *fulljid) |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
489 { |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
490 eviqs *iqn; |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
491 |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
492 iqn = iqs_new(JPACKET__GET, NS_TIME, "time", IQS_DEFAULT_TIMEOUT); |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
746
diff
changeset
|
493 xmlnode_put_attrib(iqn->xmldata, "to", fulljid); |
691
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
494 iqn->callback = &iqscallback_time; |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
495 jab_send(jc, iqn->xmldata); |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
496 } |
3c0a0a993de8
Implement IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
690
diff
changeset
|
497 |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
498 static int iqscallback_last(eviqs *iqp, xmlnode xml_result, guint iqcontext) |
1015 | 499 { |
500 xmlnode ansqry; | |
501 char *p; | |
502 char *bjid; | |
503 char *buf; | |
504 | |
505 // Leave now if we cannot process xml_result | |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
506 if (!xml_result || iqcontext) return -1; |
1015 | 507 |
508 ansqry = xmlnode_get_tag(xml_result, "query"); | |
509 if (!ansqry) { | |
510 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:last result!"); | |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
511 return 0; |
1015 | 512 } |
513 // Display IQ result sender... | |
514 p = xmlnode_get_attrib(xml_result, "from"); | |
515 if (!p) { | |
516 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:last result (no sender name)."); | |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
517 return 0; |
1015 | 518 } |
519 bjid = p; | |
520 | |
521 buf = g_strdup_printf("Received IQ:last result from <%s>", bjid); | |
522 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | |
523 | |
524 // bjid should now really be the "bare JID", let's strip the resource | |
525 p = strchr(bjid, JID_RESOURCE_SEPARATOR); | |
526 if (p) *p = '\0'; | |
527 | |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1283
diff
changeset
|
528 scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO, 0); |
1015 | 529 g_free(buf); |
530 | |
531 // Get result data... | |
532 p = xmlnode_get_attrib(ansqry, "seconds"); | |
533 if (p) { | |
534 long int s; | |
535 GString *sbuf; | |
536 sbuf = g_string_new("Idle time: "); | |
537 s = atol(p); | |
538 // Days | |
539 if (s > 86400L) { | |
540 g_string_append_printf(sbuf, "%ldd ", s/86400L); | |
541 s %= 86400L; | |
542 } | |
543 // hh:mm:ss | |
544 g_string_append_printf(sbuf, "%02ld:", s/3600L); | |
545 s %= 3600L; | |
546 g_string_append_printf(sbuf, "%02ld:%02ld", s/60L, s%60L); | |
1268
dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
Mikael Berthe <mikael@lilotux.net>
parents:
1261
diff
changeset
|
547 scr_WriteIncomingMessage(bjid, sbuf->str, |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1283
diff
changeset
|
548 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1015 | 549 g_string_free(sbuf, TRUE); |
550 } else { | |
551 scr_WriteIncomingMessage(bjid, "No idle time reported.", | |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1283
diff
changeset
|
552 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1015 | 553 } |
554 p = xmlnode_get_data(ansqry); | |
555 if (p) { | |
556 buf = g_strdup_printf("Status message: %s", p); | |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1283
diff
changeset
|
557 scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO, 0); |
1015 | 558 g_free(buf); |
559 } | |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
560 return 0; |
1015 | 561 } |
562 | |
563 void request_last(const char *fulljid) | |
564 { | |
565 eviqs *iqn; | |
566 | |
567 iqn = iqs_new(JPACKET__GET, NS_LAST, "last", IQS_DEFAULT_TIMEOUT); | |
568 xmlnode_put_attrib(iqn->xmldata, "to", fulljid); | |
569 iqn->callback = &iqscallback_last; | |
570 jab_send(jc, iqn->xmldata); | |
571 } | |
572 | |
1006 | 573 static void display_vcard_item(const char *bjid, const char *label, |
574 enum vcard_attr vcard_attrib, const char *text) | |
575 { | |
576 char *buf; | |
577 | |
578 if (!text || !bjid || !label) | |
579 return; | |
580 | |
581 buf = g_strdup_printf("%s: %s%s%s%s%s%s%s%s%s%s", label, | |
582 (vcard_attrib & vcard_home ? "[home]" : ""), | |
583 (vcard_attrib & vcard_work ? "[work]" : ""), | |
584 (vcard_attrib & vcard_postal ? "[postal]" : ""), | |
585 (vcard_attrib & vcard_voice ? "[voice]" : ""), | |
586 (vcard_attrib & vcard_fax ? "[fax]" : ""), | |
587 (vcard_attrib & vcard_cell ? "[cell]" : ""), | |
588 (vcard_attrib & vcard_inet ? "[inet]" : ""), | |
589 (vcard_attrib & vcard_pref ? "[pref]" : ""), | |
590 (vcard_attrib ? " " : ""), | |
591 text); | |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1283
diff
changeset
|
592 scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); |
1006 | 593 g_free(buf); |
594 } | |
595 | |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
596 static void handle_vcard_node(const char *barejid, xmlnode vcardnode) |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
597 { |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
598 xmlnode x; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
599 const char *p; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
600 |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
601 x = xmlnode_get_firstchild(vcardnode); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
602 for ( ; x; x = xmlnode_get_nextsibling(x)) { |
1006 | 603 const char *data; |
604 enum vcard_attr vcard_attrib = 0; | |
605 | |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
606 p = xmlnode_get_name(x); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
607 data = xmlnode_get_data(x); |
1006 | 608 if (!p || !data) |
609 continue; | |
610 | |
611 if (!strcmp(p, "FN")) | |
612 display_vcard_item(barejid, "Name", vcard_attrib, data); | |
613 else if (!strcmp(p, "NICKNAME")) | |
614 display_vcard_item(barejid, "Nickname", vcard_attrib, data); | |
615 else if (!strcmp(p, "URL")) | |
616 display_vcard_item(barejid, "URL", vcard_attrib, data); | |
617 else if (!strcmp(p, "BDAY")) | |
618 display_vcard_item(barejid, "Birthday", vcard_attrib, data); | |
619 else if (!strcmp(p, "TZ")) | |
620 display_vcard_item(barejid, "Timezone", vcard_attrib, data); | |
621 else if (!strcmp(p, "TITLE")) | |
622 display_vcard_item(barejid, "Title", vcard_attrib, data); | |
623 else if (!strcmp(p, "ROLE")) | |
624 display_vcard_item(barejid, "Role", vcard_attrib, data); | |
625 else if (!strcmp(p, "DESC")) | |
626 display_vcard_item(barejid, "Comment", vcard_attrib, data); | |
627 else if (!strcmp(p, "N")) { | |
628 data = xmlnode_get_tag_data(x, "FAMILY"); | |
629 display_vcard_item(barejid, "Family Name", vcard_attrib, data); | |
630 data = xmlnode_get_tag_data(x, "GIVEN"); | |
631 display_vcard_item(barejid, "Given Name", vcard_attrib, data); | |
632 data = xmlnode_get_tag_data(x, "MIDDLE"); | |
633 display_vcard_item(barejid, "Middle Name", vcard_attrib, data); | |
634 } else if (!strcmp(p, "ORG")) { | |
635 data = xmlnode_get_tag_data(x, "ORGNAME"); | |
636 display_vcard_item(barejid, "Organisation name", vcard_attrib, data); | |
637 data = xmlnode_get_tag_data(x, "ORGUNIT"); | |
638 display_vcard_item(barejid, "Organisation unit", vcard_attrib, data); | |
639 } else { | |
640 // The HOME, WORK and PREF attributes are common to the remaining fields | |
641 // (ADR, TEL & EMAIL) | |
642 if (xmlnode_get_tag(x, "HOME")) | |
643 vcard_attrib |= vcard_home; | |
644 if (xmlnode_get_tag(x, "WORK")) | |
645 vcard_attrib |= vcard_work; | |
646 if (xmlnode_get_tag(x, "PREF")) | |
647 vcard_attrib |= vcard_pref; | |
648 if (!strcmp(p, "ADR")) { // Address | |
1005 | 649 if (xmlnode_get_tag(x, "POSTAL")) |
1006 | 650 vcard_attrib |= vcard_postal; |
651 data = xmlnode_get_tag_data(x, "EXTADD"); | |
652 display_vcard_item(barejid, "Addr (ext)", vcard_attrib, data); | |
653 data = xmlnode_get_tag_data(x, "STREET"); | |
654 display_vcard_item(barejid, "Street", vcard_attrib, data); | |
655 data = xmlnode_get_tag_data(x, "LOCALITY"); | |
656 display_vcard_item(barejid, "Locality", vcard_attrib, data); | |
657 data = xmlnode_get_tag_data(x, "REGION"); | |
658 display_vcard_item(barejid, "Region", vcard_attrib, data); | |
659 data = xmlnode_get_tag_data(x, "PCODE"); | |
660 display_vcard_item(barejid, "Postal code", vcard_attrib, data); | |
661 data = xmlnode_get_tag_data(x, "CTRY"); | |
662 display_vcard_item(barejid, "Country", vcard_attrib, data); | |
663 } else if (!strcmp(p, "TEL")) { // Telephone | |
1005 | 664 data = xmlnode_get_tag_data(x, "NUMBER"); |
665 if (data) { | |
666 if (xmlnode_get_tag(x, "VOICE")) | |
1006 | 667 vcard_attrib |= vcard_voice; |
1005 | 668 if (xmlnode_get_tag(x, "FAX")) |
1006 | 669 vcard_attrib |= vcard_fax; |
1005 | 670 if (xmlnode_get_tag(x, "CELL")) |
1006 | 671 vcard_attrib |= vcard_cell; |
672 display_vcard_item(barejid, "Phone", vcard_attrib, data); | |
1005 | 673 } |
1006 | 674 } else if (!strcmp(p, "EMAIL")) { // Email |
675 if (xmlnode_get_tag(x, "INTERNET")) | |
676 vcard_attrib |= vcard_inet; | |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
677 data = xmlnode_get_tag_data(x, "USERID"); |
1006 | 678 display_vcard_item(barejid, "Email", vcard_attrib, data); |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
679 } |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
680 } |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
681 } |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
682 } |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
683 |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
684 static int iqscallback_vcard(eviqs *iqp, xmlnode xml_result, guint iqcontext) |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
685 { |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
686 xmlnode ansqry; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
687 char *p; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
688 char *bjid; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
689 char *buf; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
690 |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
691 // Leave now if we cannot process xml_result |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
692 if (!xml_result || iqcontext) return -1; |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
693 |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
694 // Display IQ result sender... |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
695 p = xmlnode_get_attrib(xml_result, "from"); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
696 if (!p) { |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
697 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:vCard result (no sender name)."); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
698 return 0; |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
699 } |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
700 bjid = p; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
701 |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
702 buf = g_strdup_printf("Received IQ:vCard result from <%s>", bjid); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
703 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
704 |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
705 // Get the vCard node |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
706 ansqry = xmlnode_get_tag(xml_result, "vCard"); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
707 if (!ansqry) { |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
708 scr_LogPrint(LPRINT_LOGNORM, "Empty IQ:vCard result!"); |
1340
2031f4b2cced
Fix a small memory leak
Mikael Berthe <mikael@lilotux.net>
parents:
1334
diff
changeset
|
709 g_free(buf); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
710 return 0; |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
711 } |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
712 |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
713 // bjid should really be the "bare JID", let's strip the resource |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
714 p = strchr(bjid, JID_RESOURCE_SEPARATOR); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
715 if (p) *p = '\0'; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
716 |
1290
e42f48103609
Drawing the MUC nicks by a different color
Michal 'vorner' Vaner <vorner@ucw.cz>
parents:
1283
diff
changeset
|
717 scr_WriteIncomingMessage(bjid, buf, 0, HBB_PREFIX_INFO, 0); |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
718 g_free(buf); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
719 |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
720 // Get result data... |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
721 handle_vcard_node(bjid, ansqry); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
722 return 0; |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
723 } |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
724 |
1058 | 725 void request_vcard(const char *bjid) |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
726 { |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
727 eviqs *iqn; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
728 |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
729 // Create a new IQ structure. We use NULL for the namespace because |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
730 // we'll have to use a special tag, not the usual "query" one. |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
731 iqn = iqs_new(JPACKET__GET, NULL, "vcard", IQS_DEFAULT_TIMEOUT); |
1310
a5336c44d4e2
Allow vcard requests to a full jid
Mikael Berthe <mikael@lilotux.net>
parents:
1290
diff
changeset
|
732 xmlnode_put_attrib(iqn->xmldata, "to", bjid); |
1003
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
733 // Remove the useless <query/> tag, and insert a vCard one. |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
734 xmlnode_hide(xmlnode_get_tag(iqn->xmldata, "query")); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
735 xmlnode_put_attrib(xmlnode_insert_tag(iqn->xmldata, "vCard"), |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
736 "xmlns", NS_VCARD); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
737 iqn->callback = &iqscallback_vcard; |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
738 jab_send(jc, iqn->xmldata); |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
739 } |
c8b1a52b2fd6
Initial VCard retrieval support
Mikael Berthe <mikael@lilotux.net>
parents:
1002
diff
changeset
|
740 |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
741 static void storage_bookmarks_parse_conference(xmlnode xmldata) |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
742 { |
1058 | 743 const char *fjid, *name, *autojoin; |
1379
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
744 const char *pstatus, *awhois; |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
745 char *bjid; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
746 GSList *room_elt; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
747 |
1058 | 748 fjid = xmlnode_get_attrib(xmldata, "jid"); |
749 if (!fjid) | |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
750 return; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
751 name = xmlnode_get_attrib(xmldata, "name"); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
752 autojoin = xmlnode_get_attrib(xmldata, "autojoin"); |
1379
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
753 awhois = xmlnode_get_attrib(xmldata, "autowhois"); |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
754 pstatus = xmlnode_get_tag_data(xmldata, "print_status"); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
755 |
1058 | 756 bjid = jidtodisp(fjid); // Bare jid |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
757 |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
758 // Make sure this is a room (it can be a conversion user->room) |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
759 room_elt = roster_find(bjid, jidsearch, 0); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
760 if (!room_elt) { |
1355 | 761 room_elt = roster_add_user(bjid, name, NULL, ROSTER_TYPE_ROOM, |
762 sub_none, -1); | |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
763 } else { |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
764 buddy_settype(room_elt->data, ROSTER_TYPE_ROOM); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
765 /* |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
766 // If the name is available, should we use it? |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
767 // I don't think so, it would be confusing because this item is already |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
768 // in the roster. |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
769 if (name) |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
770 buddy_setname(room_elt->data, name); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
771 */ |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
772 } |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
773 |
1379
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
774 // Set the print_status and auto_whois values |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
775 if (pstatus) { |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
776 enum room_printstatus i; |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
777 for (i = status_none; i <= status_all; i++) |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
778 if (!strcasecmp(pstatus, strprintstatus[i])) |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
779 break; |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
780 if (i <= status_all) |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
781 buddy_setprintstatus(room_elt->data, i); |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
782 } |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
783 if (awhois) { |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
784 enum room_autowhois i = autowhois_default; |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
785 if (!strcmp(awhois, "1")) |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
786 i = autowhois_on; |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
787 else if (!strcmp(awhois, "0")) |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
788 i = autowhois_off; |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
789 if (i != autowhois_default) |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
790 buddy_setautowhois(room_elt->data, i); |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
791 } |
74b7621537d7
MUC: Store room settings (print_status, auto_whois) in private storage
Mikael Berthe <mikael@lilotux.net>
parents:
1365
diff
changeset
|
792 |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
793 // Is autojoin set? |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
794 // If it is, we'll look up for more information (nick? password?) and |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
795 // try to join the room. |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
796 if (autojoin && !strcmp(autojoin, "1")) { |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
797 char *nick, *passwd; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
798 char *tmpnick = NULL; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
799 nick = xmlnode_get_tag_data(xmldata, "nick"); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
800 passwd = xmlnode_get_tag_data(xmldata, "password"); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
801 if (!nick || !*nick) |
1395
d431cd75eb53
Use bookmarked nickname when manually joining a room
Mikael Berthe <mikael@lilotux.net>
parents:
1393
diff
changeset
|
802 nick = tmpnick = default_muc_nickname(NULL); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
803 // Let's join now |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
804 scr_LogPrint(LPRINT_LOGNORM, "Auto-join bookmark <%s>", bjid); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
805 jb_room_join(bjid, nick, passwd); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
806 g_free(tmpnick); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
807 } |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
808 g_free(bjid); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
809 } |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
810 |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
811 static int iqscallback_storage_bookmarks(eviqs *iqp, xmlnode xml_result, |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
812 guint iqcontext) |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
813 { |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
814 xmlnode x, ansqry; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
815 char *p; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
816 |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
817 if (iqcontext == IQS_CONTEXT_ERROR) { |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
818 // No server support, or no bookmarks? |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
819 p = xmlnode_get_name(xmlnode_get_firstchild(xml_result)); |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
820 if (p && !strcmp(p, "item-not-found")) { |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
821 // item-no-found means the server has Private Storage, but it's |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
822 // currently empty. |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
823 xmlnode_free(bookmarks); |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
824 bookmarks = xmlnode_new_tag("storage"); |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
825 xmlnode_put_attrib(bookmarks, "xmlns", "storage:bookmarks"); |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
826 // We return 0 so that the IQ error message be |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
827 // not displayed, as it isn't a real error. |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
828 return 0; |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
829 } |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
830 return -1; // Unhandled error |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
831 } |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
832 |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
833 // Leave now if we cannot process xml_result |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
834 if (!xml_result || iqcontext) return 0; |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
835 |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
836 ansqry = xmlnode_get_tag(xml_result, "query"); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
837 ansqry = xmlnode_get_tag(ansqry, "storage"); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
838 if (!ansqry) { |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
839 scr_LogPrint(LPRINT_LOG, "Invalid IQ:private result! (storage:bookmarks)"); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
840 return 0; |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
841 } |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
842 |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
843 // Walk through the storage tags |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
844 x = xmlnode_get_firstchild(ansqry); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
845 for ( ; x; x = xmlnode_get_nextsibling(x)) { |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
846 p = xmlnode_get_name(x); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
847 // If the current node is a conference item, parse it and update the roster |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
848 if (p && !strcmp(p, "conference")) |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
849 storage_bookmarks_parse_conference(x); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
850 } |
1016 | 851 // Copy the bookmarks node |
1008
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
852 xmlnode_free(bookmarks); |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
853 bookmarks = xmlnode_dup(ansqry); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
854 return 0; |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
855 } |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
856 |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
857 static void request_storage_bookmarks(void) |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
858 { |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
859 eviqs *iqn; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
860 xmlnode x; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
861 |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
862 iqn = iqs_new(JPACKET__GET, NS_PRIVATE, "storage", IQS_DEFAULT_TIMEOUT); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
863 |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
864 x = xmlnode_insert_tag(xmlnode_get_tag(iqn->xmldata, "query"), "storage"); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
865 xmlnode_put_attrib(x, "xmlns", "storage:bookmarks"); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
866 |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
867 iqn->callback = &iqscallback_storage_bookmarks; |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
868 jab_send(jc, iqn->xmldata); |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
869 } |
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
870 |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
871 static int iqscallback_storage_rosternotes(eviqs *iqp, xmlnode xml_result, |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
872 guint iqcontext) |
1016 | 873 { |
874 xmlnode ansqry; | |
875 | |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
876 if (iqcontext == IQS_CONTEXT_ERROR) { |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
877 const char *p; |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
878 // No server support, or no roster notes? |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
879 p = xmlnode_get_name(xmlnode_get_firstchild(xml_result)); |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
880 if (p && !strcmp(p, "item-not-found")) { |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
881 // item-no-found means the server has Private Storage, but it's |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
882 // currently empty. |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
883 xmlnode_free(rosternotes); |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
884 rosternotes = xmlnode_new_tag("storage"); |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
885 xmlnode_put_attrib(rosternotes, "xmlns", "storage:rosternotes"); |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
886 // We return 0 so that the IQ error message be |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
887 // not displayed, as it isn't a real error. |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
888 return 0; |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
889 } |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
890 return -1; // Unhandled error |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
891 } |
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
892 |
1016 | 893 // Leave now if we cannot process xml_result |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
894 if (!xml_result || iqcontext) return 0; |
1016 | 895 |
896 ansqry = xmlnode_get_tag(xml_result, "query"); | |
897 ansqry = xmlnode_get_tag(ansqry, "storage"); | |
898 if (!ansqry) { | |
899 scr_LogPrint(LPRINT_LOG, "Invalid IQ:private result! " | |
900 "(storage:rosternotes)"); | |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
901 return 0; |
1016 | 902 } |
903 // Copy the rosternotes node | |
904 xmlnode_free(rosternotes); | |
905 rosternotes = xmlnode_dup(ansqry); | |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
906 return 0; |
1016 | 907 } |
908 | |
909 static void request_storage_rosternotes(void) | |
910 { | |
911 eviqs *iqn; | |
912 xmlnode x; | |
913 | |
914 iqn = iqs_new(JPACKET__GET, NS_PRIVATE, "storage", IQS_DEFAULT_TIMEOUT); | |
915 | |
916 x = xmlnode_insert_tag(xmlnode_get_tag(iqn->xmldata, "query"), "storage"); | |
917 xmlnode_put_attrib(x, "xmlns", "storage:rosternotes"); | |
918 | |
919 iqn->callback = &iqscallback_storage_rosternotes; | |
920 jab_send(jc, iqn->xmldata); | |
921 } | |
922 | |
1224
fb0460a3cf4b
Fix iqscallback_auth() when authentication fails
Mikael Berthe <mikael@lilotux.net>
parents:
1218
diff
changeset
|
923 int iqscallback_auth(eviqs *iqp, xmlnode xml_result, guint iqcontext) |
686
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
924 { |
1224
fb0460a3cf4b
Fix iqscallback_auth() when authentication fails
Mikael Berthe <mikael@lilotux.net>
parents:
1218
diff
changeset
|
925 if (iqcontext == IQS_CONTEXT_ERROR) |
fb0460a3cf4b
Fix iqscallback_auth() when authentication fails
Mikael Berthe <mikael@lilotux.net>
parents:
1218
diff
changeset
|
926 return -1; |
fb0460a3cf4b
Fix iqscallback_auth() when authentication fails
Mikael Berthe <mikael@lilotux.net>
parents:
1218
diff
changeset
|
927 |
686
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
928 if (jstate == STATE_GETAUTH) { |
745
413e95f3051a
Introduce user "events" list
Mikael Berthe <mikael@lilotux.net>
parents:
705
diff
changeset
|
929 eviqs *iqn; |
686
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
930 |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
931 if (xml_result) { |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
932 xmlnode x = xmlnode_get_tag(xml_result, "query"); |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
933 if (x && !xmlnode_get_tag(x, "digest")) |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
934 jc->sid = 0; |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
935 } |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
936 |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
937 iqn = iqs_new(JPACKET__SET, NS_AUTH, "auth", IQS_DEFAULT_TIMEOUT); |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
938 iqn->callback = &iqscallback_auth; |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
939 jab_auth_mcabber(jc, iqn->xmldata); |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
940 jab_send(jc, iqn->xmldata); |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
941 jstate = STATE_SENDAUTH; |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
942 } else if (jstate == STATE_SENDAUTH) { |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
943 request_roster(); |
1004
b57a01ffeed6
Use existing conference bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1003
diff
changeset
|
944 request_storage_bookmarks(); |
1016 | 945 request_storage_rosternotes(); |
686
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
946 jstate = STATE_LOGGED; |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
947 } |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
948 return 0; |
686
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
949 } |
98de2d166a11
Use the new IQ system for authentication
Mikael Berthe <mikael@lilotux.net>
parents:
685
diff
changeset
|
950 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
951 static void handle_iq_result(jconn conn, char *from, xmlnode xmldata) |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
952 { |
1353
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
953 char *id = xmlnode_get_attrib(xmldata, "id"); |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
954 |
685
f033345d1315
Call IQ callback function when receiving a RESULT packet
Mikael Berthe <mikael@lilotux.net>
parents:
684
diff
changeset
|
955 if (!id) { |
596
6c7fd289648f
Clean up handle_iq_result()
Mikael Berthe <mikael@lilotux.net>
parents:
595
diff
changeset
|
956 scr_LogPrint(LPRINT_LOG, "IQ result stanza with no ID, ignored."); |
6c7fd289648f
Clean up handle_iq_result()
Mikael Berthe <mikael@lilotux.net>
parents:
595
diff
changeset
|
957 return; |
6c7fd289648f
Clean up handle_iq_result()
Mikael Berthe <mikael@lilotux.net>
parents:
595
diff
changeset
|
958 } |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
959 |
1353
7caedca15e50
Add post-connect internal hook
Mikael Berthe <mikael@lilotux.net>
parents:
1348
diff
changeset
|
960 (void)iqs_callback(id, xmldata, IQS_CONTEXT_RESULT); |
426
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
961 } |
2706ef3e25a7
Better handling of server error codes/messages
Mikael Berthe <mikael@lilotux.net>
parents:
421
diff
changeset
|
962 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
963 // FIXME highly duplicated code |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
964 static void send_iq_not_implemented(jconn conn, char *from, xmlnode xmldata) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
965 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
966 xmlnode x, y, z; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
967 // Not implemented. |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
968 x = xmlnode_dup(xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
969 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
970 xmlnode_hide_attrib(x, "from"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
971 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
972 xmlnode_put_attrib(x, "type", TMSG_ERROR); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
973 y = xmlnode_insert_tag(x, TMSG_ERROR); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
974 xmlnode_put_attrib(y, "code", "501"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
975 xmlnode_put_attrib(y, "type", "cancel"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
976 z = xmlnode_insert_tag(y, "feature-not-implemented"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
977 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
978 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
979 jab_send(conn, x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
980 xmlnode_free(x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
981 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
982 |
1261
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
983 // FIXME highly duplicated code |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
984 static void send_iq_not_available(jconn conn, char *from, xmlnode xmldata) |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
985 { |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
986 xmlnode x, y, z; |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
987 // Not available. |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
988 x = xmlnode_dup(xmldata); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
989 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
990 xmlnode_hide_attrib(x, "from"); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
991 |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
992 xmlnode_put_attrib(x, "type", TMSG_ERROR); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
993 y = xmlnode_insert_tag(x, TMSG_ERROR); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
994 xmlnode_put_attrib(y, "code", "503"); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
995 xmlnode_put_attrib(y, "type", "cancel"); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
996 z = xmlnode_insert_tag(y, "service-unavailable"); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
997 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
998 |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
999 jab_send(conn, x); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1000 xmlnode_free(x); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1001 } |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1002 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1003 /* |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1004 static void send_iq_commands_bad_action(jconn conn, char *from, xmlnode xmldata) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1005 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1006 xmlnode x, y, z; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1007 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1008 x = xmlnode_dup(xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1009 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1010 xmlnode_hide_attrib(x, "from"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1011 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1012 xmlnode_put_attrib(x, "type", TMSG_ERROR); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1013 y = xmlnode_insert_tag(x, TMSG_ERROR); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1014 xmlnode_put_attrib(y, "code", "400"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1015 xmlnode_put_attrib(y, "type", "modify"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1016 z = xmlnode_insert_tag(y, "bad-request"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1017 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1018 z = xmlnode_insert_tag(y, "bad-action"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1019 xmlnode_put_attrib(z, "xmlns", NS_COMMANDS); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1020 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1021 jab_send(conn, x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1022 xmlnode_free(x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1023 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1024 */ |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1025 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1026 static void send_iq_forbidden(jconn conn, char *from, xmlnode xmldata) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1027 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1028 xmlnode x, y, z; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1029 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1030 x = xmlnode_dup(xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1031 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1032 xmlnode_hide_attrib(x, "from"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1033 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1034 xmlnode_put_attrib(x, "type", TMSG_ERROR); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1035 y = xmlnode_insert_tag(x, TMSG_ERROR); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1036 xmlnode_put_attrib(y, "code", "403"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1037 xmlnode_put_attrib(y, "type", "cancel"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1038 z = xmlnode_insert_tag(y, "forbidden"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1039 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1040 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1041 jab_send(conn, x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1042 xmlnode_free(x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1043 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1044 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1045 static void send_iq_commands_malformed_action(jconn conn, char *from, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1046 xmlnode xmldata) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1047 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1048 xmlnode x, y, z; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1049 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1050 x = xmlnode_dup(xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1051 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1052 xmlnode_hide_attrib(x, "from"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1053 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1054 xmlnode_put_attrib(x, "type", TMSG_ERROR); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1055 y = xmlnode_insert_tag(x, TMSG_ERROR); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1056 xmlnode_put_attrib(y, "code", "400"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1057 xmlnode_put_attrib(y, "type", "modify"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1058 z = xmlnode_insert_tag(y, "bad-request"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1059 xmlnode_put_attrib(z, "xmlns", NS_XMPP_STANZAS); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1060 z = xmlnode_insert_tag(y, "malformed-action"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1061 xmlnode_put_attrib(z, "xmlns", NS_COMMANDS); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1062 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1063 jab_send(conn, x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1064 xmlnode_free(x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1065 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1066 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1067 static void handle_iq_commands_list(jconn conn, char *from, const char *id, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1068 xmlnode xmldata) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1069 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1070 xmlnode x; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1071 xmlnode myquery; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1072 jid requester_jid; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1073 const struct adhoc_command *command; |
1461
8fa24a6d1a93
Improve Remote Controlling Clients
Mikael Berthe <mikael@lilotux.net>
parents:
1460
diff
changeset
|
1074 const char *node; |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1075 bool from_self; |
1461
8fa24a6d1a93
Improve Remote Controlling Clients
Mikael Berthe <mikael@lilotux.net>
parents:
1460
diff
changeset
|
1076 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1077 x = jutil_iqnew(JPACKET__RESULT, NS_DISCO_ITEMS); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1078 xmlnode_put_attrib(x, "id", id); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1079 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1080 myquery = xmlnode_get_tag(x, "query"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1081 |
1461
8fa24a6d1a93
Improve Remote Controlling Clients
Mikael Berthe <mikael@lilotux.net>
parents:
1460
diff
changeset
|
1082 node = xmlnode_get_attrib(xmlnode_get_tag(xmldata, "query"), "node"); |
8fa24a6d1a93
Improve Remote Controlling Clients
Mikael Berthe <mikael@lilotux.net>
parents:
1460
diff
changeset
|
1083 if (node) |
8fa24a6d1a93
Improve Remote Controlling Clients
Mikael Berthe <mikael@lilotux.net>
parents:
1460
diff
changeset
|
1084 xmlnode_put_attrib(myquery, "node", node); |
8fa24a6d1a93
Improve Remote Controlling Clients
Mikael Berthe <mikael@lilotux.net>
parents:
1460
diff
changeset
|
1085 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1086 requester_jid = jid_new(conn->p, xmlnode_get_attrib(xmldata, "from")); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1087 from_self = !jid_cmpx(conn->user, requester_jid, JID_USER | JID_SERVER); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1088 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1089 for (command = adhoc_command_list ; command->name ; command++) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1090 if (!command->only_for_self || from_self) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1091 xmlnode item; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1092 item = xmlnode_insert_tag(myquery, "item"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1093 xmlnode_put_attrib(item, "node", command->name); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1094 xmlnode_put_attrib(item, "name", command->description); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1095 xmlnode_put_attrib(item, "jid", jid_full(conn->user)); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1096 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1097 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1098 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1099 jab_send(jc, x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1100 xmlnode_free(x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1101 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1102 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1103 static void xmlnode_insert_dataform_result_message(xmlnode node, char *message) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1104 { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1105 xmlnode x, field, value; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1106 |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1107 x = xmlnode_insert_tag(node, "x"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1108 xmlnode_put_attrib(x, "type", "result"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1109 xmlnode_put_attrib(x, "xmlns", "jabber:x:data"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1110 |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1111 field = xmlnode_insert_tag(x, "field"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1112 xmlnode_put_attrib(field, "type", "text-single"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1113 xmlnode_put_attrib(field, "var", "message"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1114 |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1115 value = xmlnode_insert_tag(field, "value"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1116 xmlnode_insert_cdata(value, message, -1); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1117 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1118 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1119 static char *generate_session_id(char *prefix) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1120 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1121 char *result; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1122 static int counter = 0; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1123 counter++; |
1460 | 1124 // TODO better use timestamp? |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1125 result = g_strdup_printf("%s-%i", prefix, counter); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1126 return result; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1127 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1128 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1129 static void handle_iq_command_set_status(jconn conn, char *from, const char *id, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1130 xmlnode xmldata) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1131 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1132 char *action, *node, *sessionid; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1133 xmlnode iq, command, x, y; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1134 const struct adhoc_status *s; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1135 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1136 x = xmlnode_get_tag(xmldata, "command"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1137 action = xmlnode_get_attrib(x, "action"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1138 node = xmlnode_get_attrib(x, "node"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1139 sessionid = xmlnode_get_attrib(x, "sessionid"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1140 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1141 iq = xmlnode_new_tag("iq"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1142 command = xmlnode_insert_tag(iq, "command"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1143 xmlnode_put_attrib(command, "node", node); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1144 xmlnode_put_attrib(command, "xmlns", NS_COMMANDS); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1145 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1146 if (!sessionid) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1147 xmlnode value; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1148 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1149 sessionid = generate_session_id("set-status"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1150 xmlnode_put_attrib(command, "sessionid", sessionid); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1151 g_free(sessionid); |
1492
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1152 sessionid = NULL; |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1153 xmlnode_put_attrib(command, "status", "executing"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1154 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1155 x = xmlnode_insert_tag(command, "x"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1156 xmlnode_put_attrib(x, "type", "form"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1157 xmlnode_put_attrib(x, "xmlns", "jabber:x:data"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1158 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1159 y = xmlnode_insert_tag(x, "title"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1160 xmlnode_insert_cdata(y, "Change Status", -1); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1161 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1162 y = xmlnode_insert_tag(x, "instructions"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1163 xmlnode_insert_cdata(y, "Choose the status and status message", -1); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1164 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1165 // TODO see if factorisation is possible |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1166 // (with xmlnode_insert_dataform_result_message) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1167 y = xmlnode_insert_tag(x, "field"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1168 xmlnode_put_attrib(y, "type", "hidden"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1169 xmlnode_put_attrib(y, "var", "FORM_TYPE"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1170 |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1171 value = xmlnode_insert_tag(y, "value"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1172 xmlnode_insert_cdata(value, "http://jabber.org/protocol/rc", -1); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1173 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1174 y = xmlnode_insert_tag(x, "field"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1175 xmlnode_put_attrib(y, "type", "list-single"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1176 xmlnode_put_attrib(y, "var", "status"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1177 xmlnode_put_attrib(y, "label", "Status"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1178 xmlnode_insert_tag(y, "required"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1179 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1180 value = xmlnode_insert_tag(y, "value"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1181 // TODO current status |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1182 xmlnode_insert_cdata(value, "online", -1); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1183 for (s = adhoc_status_list; s->name; s++) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1184 xmlnode option = xmlnode_insert_tag(y, "option"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1185 value = xmlnode_insert_tag(option, "value"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1186 xmlnode_insert_cdata(value, s->name, -1); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1187 xmlnode_put_attrib(option, "label", s->description); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1188 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1189 // TODO add priority ? |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1190 // I do not think this is useful, user should not have to care of the |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1191 // priority like gossip and gajim do (misc) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1192 y = xmlnode_insert_tag(x, "field"); |
1575
8e52ce94eee0
Change dataform s/text-multi/text-single to reflect the UI (suggested by ISBear)
franky@veqlargh.fs
parents:
1574
diff
changeset
|
1193 xmlnode_put_attrib(y, "type", "text-single"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1194 xmlnode_put_attrib(y, "var", "status-message"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1195 xmlnode_put_attrib(y, "label", "Message"); |
1574
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1196 } else if (action && !strcmp(action, "cancel")) { |
1492
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1197 xmlnode_put_attrib(command, "status", "canceled"); |
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1198 } else { // (if sessionid and not canceled) |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1199 y = xmlnode_get_tag(x, "x?xmlns=jabber:x:data"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1200 if (y) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1201 char *value, *message; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1202 value = xmlnode_get_tag_data(xmlnode_get_tag(y, "field?var=status"), |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1203 "value"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1204 message = xmlnode_get_tag_data(xmlnode_get_tag(y, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1205 "field?var=status-message"), "value"); |
1574
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1206 if (value) { |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1207 for (s = adhoc_status_list; s->name && strcmp(s->name, value); s++); |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1208 if (s->name) { |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1209 char *status = g_strdup_printf("%s %s", s->status, |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1210 message ? message : ""); |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1211 cmd_setstatus(NULL, status); |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1212 g_free(status); |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1213 xmlnode_put_attrib(command, "status", "completed"); |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1214 xmlnode_put_attrib(iq, "type", "result"); |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1215 xmlnode_insert_dataform_result_message(command, |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1216 "Status has been changed"); |
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1217 } |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1218 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1219 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1220 } |
1492
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1221 if (sessionid) |
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1222 xmlnode_put_attrib(command, "sessionid", sessionid); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1223 xmlnode_put_attrib(iq, "to", xmlnode_get_attrib(xmldata, "from")); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1224 xmlnode_put_attrib(iq, "id", id); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1225 jab_send(jc, iq); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1226 xmlnode_free(iq); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1227 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1228 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1229 static void _callback_foreach_buddy_groupchat(gpointer rosterdata, void *param) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1230 { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1231 xmlnode value, option; |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1232 xmlnode *field; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1233 const char *room_jid, *nickname; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1234 char *desc; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1235 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1236 room_jid = buddy_getjid(rosterdata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1237 if (!room_jid) return; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1238 nickname = buddy_getnickname(rosterdata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1239 if (!nickname) return; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1240 field = param; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1241 |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1242 option = xmlnode_insert_tag(*field, "option"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1243 value = xmlnode_insert_tag(option, "value"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1244 xmlnode_insert_cdata(value, room_jid, -1); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1245 desc = g_strdup_printf("%s on %s", nickname, room_jid); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1246 xmlnode_put_attrib(option, "label", desc); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1247 g_free(desc); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1248 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1249 |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1250 static void handle_iq_command_leave_groupchats(jconn conn, char *from, |
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1251 const char *id, xmlnode xmldata) |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1252 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1253 char *action, *node, *sessionid; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1254 xmlnode iq, command, x; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1255 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1256 x = xmlnode_get_tag(xmldata, "command"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1257 action = xmlnode_get_attrib(x, "action"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1258 node = xmlnode_get_attrib(x, "node"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1259 sessionid = xmlnode_get_attrib(x, "sessionid"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1260 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1261 iq = xmlnode_new_tag("iq"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1262 command = xmlnode_insert_tag(iq, "command"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1263 xmlnode_put_attrib(command, "node", node); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1264 xmlnode_put_attrib(command, "xmlns", NS_COMMANDS); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1265 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1266 if (!sessionid) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1267 xmlnode title, instructions, field, value; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1268 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1269 sessionid = generate_session_id("leave-groupchats"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1270 xmlnode_put_attrib(command, "sessionid", sessionid); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1271 g_free(sessionid); |
1492
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1272 sessionid = NULL; |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1273 xmlnode_put_attrib(command, "status", "executing"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1274 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1275 x = xmlnode_insert_tag(command, "x"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1276 xmlnode_put_attrib(x, "type", "form"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1277 xmlnode_put_attrib(x, "xmlns", "jabber:x:data"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1278 |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1279 title = xmlnode_insert_tag(x, "title"); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1280 xmlnode_insert_cdata(title, "Leave groupchat(s)", -1); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1281 |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1282 instructions = xmlnode_insert_tag(x, "instructions"); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1283 xmlnode_insert_cdata(instructions, "What groupchats do you want to leave?", |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1284 -1); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1285 |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1286 field = xmlnode_insert_tag(x, "field"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1287 xmlnode_put_attrib(field, "type", "hidden"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1288 xmlnode_put_attrib(field, "var", "FORM_TYPE"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1289 |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1290 value = xmlnode_insert_tag(field, "value"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1291 xmlnode_insert_cdata(value, "http://jabber.org/protocol/rc", -1); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1292 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1293 field = xmlnode_insert_tag(x, "field"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1294 xmlnode_put_attrib(field, "type", "list-multi"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1295 xmlnode_put_attrib(field, "var", "groupchats"); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1296 xmlnode_put_attrib(field, "label", "Groupchats: "); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1297 xmlnode_insert_tag(field, "required"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1298 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1299 foreach_buddy(ROSTER_TYPE_ROOM, &_callback_foreach_buddy_groupchat, &field); |
1574
d8a016f76ff7
Fix segfaults when receiving malformed XEP-0146 packets
franky@veqlargh.fs
parents:
1558
diff
changeset
|
1300 } else if (action && !strcmp(action, "cancel")) { |
1492
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1301 xmlnode_put_attrib(command, "status", "canceled"); |
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1302 } else { // (if sessionid and not canceled) |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1303 xmlnode form = xmlnode_get_tag(x, "x?xmlns=jabber:x:data"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1304 if (form) { |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1305 xmlnode x, gc; |
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1306 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1307 xmlnode_put_attrib(command, "status", "completed"); |
1476
77afd831f8f7
Avoid mixed declarations and code
Mikael Berthe <mikael@lilotux.net>
parents:
1461
diff
changeset
|
1308 gc = xmlnode_get_tag(form, "field?var=groupchats"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1309 |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1310 for (x = xmlnode_get_firstchild(gc) ; x ; x = xmlnode_get_nextsibling(x)) |
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1311 { |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1312 char* to_leave = xmlnode_get_tag_data(x, "value"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1313 if (to_leave) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1314 GList* b = buddy_search_jid(to_leave); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1315 if (b) |
1492
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1316 cmd_room_leave(b->data, "Requested by remote command"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1317 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1318 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1319 xmlnode_put_attrib(iq, "type", "result"); |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1320 xmlnode_insert_dataform_result_message(command, |
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1321 "Groupchats have been left"); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1322 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1323 } |
1492
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1324 if (sessionid) |
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1325 xmlnode_put_attrib(command, "sessionid", sessionid); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1326 xmlnode_put_attrib(iq, "to", xmlnode_get_attrib(xmldata, "from")); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1327 xmlnode_put_attrib(iq, "id", id); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1328 jab_send(jc, iq); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1329 xmlnode_free(iq); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1330 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1331 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1332 static void handle_iq_commands(jconn conn, char *from, const char *id, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1333 xmlnode xmldata) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1334 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1335 jid requester_jid; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1336 xmlnode x; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1337 const struct adhoc_command *command; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1338 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1339 requester_jid = jid_new(conn->p, xmlnode_get_attrib(xmldata, "from")); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1340 x = xmlnode_get_tag(xmldata, "command"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1341 if (!jid_cmpx(conn->user, requester_jid, JID_USER | JID_SERVER) ) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1342 char *action, *node; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1343 action = xmlnode_get_attrib(x, "action"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1344 node = xmlnode_get_attrib(x, "node"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1345 // action can be NULL, in which case it seems to take the default, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1346 // ie execute |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1347 if (!action || !strcmp(action, "execute") || !strcmp(action, "cancel") |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1348 || !strcmp(action, "next") || !strcmp(action, "complete")) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1349 for (command = adhoc_command_list; command->name; command++) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1350 if (!strcmp(node, command->name)) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1351 command->callback(conn, from, id, xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1352 } |
1159
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1353 // "prev" action will get there, as we do not implement it, |
53c0c5be43fa
Small fixes, typos and cleanups
Mikael Berthe <mikael@lilotux.net>
parents:
1158
diff
changeset
|
1354 // and do not authorize it |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1355 } else { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1356 send_iq_commands_malformed_action(conn, from, xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1357 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1358 } else { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1359 send_iq_forbidden(conn, from, xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1360 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1361 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1362 |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1363 static void handle_iq_disco_items(jconn conn, char *from, const char *id, |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1364 xmlnode xmldata) |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1365 { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1366 xmlnode x; |
1461
8fa24a6d1a93
Improve Remote Controlling Clients
Mikael Berthe <mikael@lilotux.net>
parents:
1460
diff
changeset
|
1367 const char *node; |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1368 x = xmlnode_get_tag(xmldata, "query"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1369 node = xmlnode_get_attrib(x, "node"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1370 if (node) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1371 if (!strcmp(node, NS_COMMANDS)) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1372 handle_iq_commands_list(conn, from, id, xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1373 } else { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1374 send_iq_not_implemented(conn, from, xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1375 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1376 } else { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1377 // not sure about this one |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1378 send_iq_not_implemented(conn, from, xmldata); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1379 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1380 } |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1381 |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1382 // disco_info_set_ext(ansquery, ext) |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1383 // Add features attributes to ansquery for extension ext. |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1384 static void disco_info_set_ext(xmlnode ansquery, const char *ext) |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1385 { |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1386 char *nodename; |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1387 nodename = g_strdup_printf("%s#%s", MCABBER_CAPS_NODE, ext); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1388 xmlnode_put_attrib(ansquery, "node", nodename); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1389 g_free(nodename); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1390 if (!strcasecmp(ext, "csn")) { |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1391 // I guess it's ok to send this even if it's not compiled in. |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1392 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1393 "var", NS_CHATSTATES); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1394 } |
1255
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1395 if (!strcasecmp(ext, "iql")) { |
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1396 // I guess it's ok to send this even if it's not compiled in. |
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1397 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1398 "var", NS_LAST); |
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1399 } |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1400 } |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1401 |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1402 // disco_info_set_default(ansquery, entitycaps) |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1403 // Add features attributes to ansquery. If entitycaps is TRUE, assume |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1404 // that we're answering an Entity Caps request (if not, the request was |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1405 // a basic discovery query). |
1218
ab5de2ed2b7e
Simplify entity_version()
Mikael Berthe <mikael@lilotux.net>
parents:
1217
diff
changeset
|
1406 // Please change the entity version string if you modify mcabber disco |
ab5de2ed2b7e
Simplify entity_version()
Mikael Berthe <mikael@lilotux.net>
parents:
1217
diff
changeset
|
1407 // source code, so that it doesn't conflict with the upstream client. |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1408 static void disco_info_set_default(xmlnode ansquery, guint entitycaps) |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1409 { |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1410 xmlnode y; |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1411 char *eversion; |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1412 |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1413 eversion = g_strdup_printf("%s#%s", MCABBER_CAPS_NODE, entity_version()); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1414 xmlnode_put_attrib(ansquery, "node", eversion); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1415 g_free(eversion); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1416 |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1417 y = xmlnode_insert_tag(ansquery, "identity"); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1418 xmlnode_put_attrib(y, "category", "client"); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1419 xmlnode_put_attrib(y, "type", "pc"); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1420 xmlnode_put_attrib(y, "name", PACKAGE_NAME); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1421 |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1422 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1423 "var", NS_DISCO_INFO); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1424 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1425 "var", NS_MUC); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1426 #ifdef JEP0085 |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1427 // Advertise ChatStates only if we're not using Entity Capabilities |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1428 if (!entitycaps) |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1429 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1430 "var", NS_CHATSTATES); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1431 #endif |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1432 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1433 "var", NS_TIME); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1434 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
1283
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1435 "var", NS_XMPP_TIME); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1436 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1437 "var", NS_VERSION); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1438 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1439 "var", NS_PING); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1440 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1441 "var", NS_COMMANDS); |
1255
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1442 if (!entitycaps) |
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1443 xmlnode_put_attrib(xmlnode_insert_tag(ansquery, "feature"), |
ceada40bbe20
Update Entity Capabilities (add iq:last)
Mikael Berthe <mikael@lilotux.net>
parents:
1254
diff
changeset
|
1444 "var", NS_LAST); |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1445 } |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1446 |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1447 static void handle_iq_disco_info(jconn conn, char *from, const char *id, |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1448 xmlnode xmldata) |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1449 { |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1450 xmlnode x; |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1451 xmlnode myquery; |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1452 char *node; |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1453 |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1454 x = jutil_iqnew(JPACKET__RESULT, NS_DISCO_INFO); |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1455 xmlnode_put_attrib(x, "id", id); |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1456 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1457 myquery = xmlnode_get_tag(x, "query"); |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1458 |
1215
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1459 node = xmlnode_get_attrib(xmlnode_get_tag(xmldata, "query"), "node"); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1460 if (node && startswith(node, MCABBER_CAPS_NODE "#", FALSE)) { |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1461 const char *param = node+strlen(MCABBER_CAPS_NODE)+1; |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1462 if (!strcmp(param, entity_version())) |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1463 disco_info_set_default(myquery, TRUE); // client#version |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1464 else |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1465 disco_info_set_ext(myquery, param); // client#extension |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1466 } else { |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1467 // Basic discovery request |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1468 disco_info_set_default(myquery, FALSE); |
80c095886fb5
Entity Capabilities support (XEP-0115)
Mikael Berthe <mikael@lilotux.net>
parents:
1213
diff
changeset
|
1469 } |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1470 |
1134 | 1471 jab_send(jc, x); |
1472 xmlnode_free(x); | |
1473 } | |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1474 |
1558
3df441efb7c2
Fix gcc warnings related to inline/static uses
Mikael Berthe <mikael@lilotux.net>
parents:
1498
diff
changeset
|
1475 double seconds_since_last_use(void) |
1254
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1476 { |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1477 return difftime(time(NULL), iqlast); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1478 } |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1479 |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1480 static void handle_iq_last(jconn conn, char *from, const char *id, |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1481 xmlnode xmldata) |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1482 { |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1483 xmlnode x; |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1484 xmlnode myquery; |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1485 char *seconds; |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1486 |
1498
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1487 if (!settings_opt_get_int("iq_hide_requests")) { |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1488 scr_LogPrint(LPRINT_LOGNORM, "Received an IQ last time request from <%s>", |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1489 from); |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1490 } |
1254
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1491 |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1492 x = jutil_iqnew(JPACKET__RESULT, NS_LAST); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1493 xmlnode_put_attrib(x, "id", id); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1494 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1495 myquery = xmlnode_get_tag(x, "query"); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1496 seconds = g_strdup_printf("%.0f", seconds_since_last_use()); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1497 xmlnode_put_attrib(myquery, "seconds", seconds); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1498 g_free(seconds); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1499 |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1500 jab_send(jc, x); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1501 xmlnode_free(x); |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1502 } |
401639413340
More jabber:iq:last support... (misc)
Mikael Berthe <mikael@lilotux.net>
parents:
1224
diff
changeset
|
1503 |
1134 | 1504 static void handle_iq_ping(jconn conn, char *from, const char *id, |
1505 xmlnode xmldata) | |
1506 { | |
1507 xmlnode x; | |
1508 x = jutil_iqresult(xmldata); | |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1509 jab_send(jc, x); |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1510 } |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1511 |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1512 static void handle_iq_version(jconn conn, char *from, const char *id, |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1513 xmlnode xmldata) |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1514 { |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1515 xmlnode x; |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1516 xmlnode myquery; |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1517 char *os = NULL; |
814
109dcf5fc111
Use hgcset (if available) when answering to IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
782
diff
changeset
|
1518 char *ver = mcabber_version(); |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1519 |
1498
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1520 if (!settings_opt_get_int("iq_hide_requests")) { |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1521 scr_LogPrint(LPRINT_LOGNORM, "Received an IQ version request from <%s>", |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1522 from); |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1523 } |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1524 |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1525 if (!settings_opt_get_int("iq_version_hide_os")) { |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1526 struct utsname osinfo; |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1527 uname(&osinfo); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1528 os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release, |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1529 osinfo.machine); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1530 } |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1531 |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1532 x = jutil_iqnew(JPACKET__RESULT, NS_VERSION); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1533 xmlnode_put_attrib(x, "id", id); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1534 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1535 myquery = xmlnode_get_tag(x, "query"); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1536 |
814
109dcf5fc111
Use hgcset (if available) when answering to IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
782
diff
changeset
|
1537 xmlnode_insert_cdata(xmlnode_insert_tag(myquery, "name"), PACKAGE_NAME, -1); |
109dcf5fc111
Use hgcset (if available) when answering to IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
782
diff
changeset
|
1538 xmlnode_insert_cdata(xmlnode_insert_tag(myquery, "version"), ver, -1); |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1539 if (os) { |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1540 xmlnode_insert_cdata(xmlnode_insert_tag(myquery, "os"), os, -1); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1541 g_free(os); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1542 } |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1543 |
814
109dcf5fc111
Use hgcset (if available) when answering to IQ:version requests
Mikael Berthe <mikael@lilotux.net>
parents:
782
diff
changeset
|
1544 g_free(ver); |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1545 jab_send(jc, x); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1546 xmlnode_free(x); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1547 } |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1548 |
1361 | 1549 // This function borrows some code from the Pidgin project |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1550 static void handle_iq_time(jconn conn, char *from, const char *id, |
1283
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1551 xmlnode xmldata) |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1552 { |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1553 xmlnode x; |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1554 xmlnode myquery; |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1555 char *buf, *utf8_buf; |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1556 time_t now_t; |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1557 struct tm *now; |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1558 |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1559 time(&now_t); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1560 |
1498
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1561 if (!settings_opt_get_int("iq_hide_requests")) { |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1562 scr_LogPrint(LPRINT_LOGNORM, "Received an IQ time request from <%s>", from); |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1563 } |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1564 |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1565 buf = g_new0(char, 512); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1566 |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1567 x = jutil_iqnew(JPACKET__RESULT, NS_TIME); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1568 xmlnode_put_attrib(x, "id", id); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1569 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1570 myquery = xmlnode_get_tag(x, "query"); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1571 |
703
8cbcbff8de7d
Fix UTC time in IQ:version queries
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1572 now = gmtime(&now_t); |
8cbcbff8de7d
Fix UTC time in IQ:version queries
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1573 |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1574 strftime(buf, 512, "%Y%m%dT%T", now); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1575 xmlnode_insert_cdata(xmlnode_insert_tag(myquery, "utc"), buf, -1); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1576 |
703
8cbcbff8de7d
Fix UTC time in IQ:version queries
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1577 now = localtime(&now_t); |
8cbcbff8de7d
Fix UTC time in IQ:version queries
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1578 |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1579 strftime(buf, 512, "%Z", now); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1580 if ((utf8_buf = to_utf8(buf))) { |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1581 xmlnode_insert_cdata(xmlnode_insert_tag(myquery, "tz"), utf8_buf, -1); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1582 g_free(utf8_buf); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1583 } |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1584 |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1585 strftime(buf, 512, "%d %b %Y %T", now); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1586 if ((utf8_buf = to_utf8(buf))) { |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1587 xmlnode_insert_cdata(xmlnode_insert_tag(myquery, "display"), utf8_buf, -1); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1588 g_free(utf8_buf); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1589 } |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1590 |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1591 jab_send(jc, x); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1592 xmlnode_free(x); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1593 g_free(buf); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1594 } |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1595 |
1361 | 1596 // This function borrows some code from the Pidgin project |
1283
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1597 static void handle_iq_time202(jconn conn, char *from, const char *id, |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1598 xmlnode xmldata) |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1599 { |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1600 xmlnode x; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1601 xmlnode myquery; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1602 char *buf, *utf8_buf; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1603 time_t now_t; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1604 struct tm *now; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1605 char const *sign; |
1393
216b4da93e08
Do not use struct tm's tm_gmtoff if not available
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
1606 int diff = 0; |
1283
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1607 |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1608 time(&now_t); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1609 |
1498
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1610 if (!settings_opt_get_int("iq_hide_requests")) { |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1611 scr_LogPrint(LPRINT_LOGNORM, "Received an IQ time request from <%s>", from); |
2eaa52d314e3
Add option 'iq_hide_requests'
Mikael Berthe <mikael@lilotux.net>
parents:
1492
diff
changeset
|
1612 } |
1283
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1613 |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1614 buf = g_new0(char, 512); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1615 |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1616 x = jutil_iqnew(JPACKET__RESULT, NULL); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1617 xmlnode_hide(xmlnode_get_tag(x, "query")); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1618 xmlnode_put_attrib(xmlnode_insert_tag(x, "time"), "xmlns", NS_XMPP_TIME); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1619 xmlnode_put_attrib(x, "id", id); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1620 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1621 myquery = xmlnode_get_tag(x, "time"); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1622 |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1623 now = localtime(&now_t); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1624 |
1393
216b4da93e08
Do not use struct tm's tm_gmtoff if not available
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
1625 if (now->tm_isdst >= 0) { |
216b4da93e08
Do not use struct tm's tm_gmtoff if not available
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
1626 #if defined HAVE_TM_GMTOFF |
1283
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1627 diff = now->tm_gmtoff; |
1393
216b4da93e08
Do not use struct tm's tm_gmtoff if not available
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
1628 #elif defined HAVE_TIMEZONE |
216b4da93e08
Do not use struct tm's tm_gmtoff if not available
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
1629 tzset(); |
216b4da93e08
Do not use struct tm's tm_gmtoff if not available
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
1630 diff = -timezone; |
216b4da93e08
Do not use struct tm's tm_gmtoff if not available
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
1631 #endif |
216b4da93e08
Do not use struct tm's tm_gmtoff if not available
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
1632 } |
216b4da93e08
Do not use struct tm's tm_gmtoff if not available
Mikael Berthe <mikael@lilotux.net>
parents:
1379
diff
changeset
|
1633 |
1283
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1634 if (diff < 0) { |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1635 sign = "-"; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1636 diff = -diff; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1637 } else { |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1638 sign = "+"; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1639 } |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1640 diff /= 60; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1641 snprintf(buf, 512, "%c%02d:%02d", *sign, diff / 60, diff % 60); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1642 if ((utf8_buf = to_utf8(buf))) { |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1643 xmlnode_insert_cdata(xmlnode_insert_tag(myquery, "tzo"), utf8_buf, -1); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1644 g_free(utf8_buf); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1645 } |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1646 |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1647 now = gmtime(&now_t); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1648 |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1649 strftime(buf, 512, "%Y-%m-%dT%TZ", now); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1650 xmlnode_insert_cdata(xmlnode_insert_tag(myquery, "utc"), buf, -1); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1651 |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1652 jab_send(jc, x); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1653 xmlnode_free(x); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1654 g_free(buf); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1655 } |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1656 |
1361 | 1657 // This function borrows some code from the Pidgin project |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1658 static void handle_iq_get(jconn conn, char *from, xmlnode xmldata) |
31 | 1659 { |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1660 const char *id, *ns; |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1661 xmlnode x; |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1662 guint iq_not_implemented = FALSE; |
31 | 1663 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1664 id = xmlnode_get_attrib(xmldata, "id"); |
607 | 1665 if (!id) { |
1666 scr_LogPrint(LPRINT_LOG, "IQ get stanza with no ID, ignored."); | |
1667 return; | |
1668 } | |
31 | 1669 |
1134 | 1670 x = xmlnode_get_tag(xmldata, "ping"); |
1671 ns = xmlnode_get_attrib(x, "xmlns"); | |
1672 if (ns && !strcmp(ns, NS_PING)) { | |
1673 handle_iq_ping(conn, from, id, xmldata); | |
1674 return; | |
1675 } | |
1676 | |
1283
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1677 x = xmlnode_get_tag(xmldata, "time"); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1678 ns = xmlnode_get_attrib(x, "xmlns"); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1679 if (ns && !strcmp(ns, NS_XMPP_TIME)) { |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1680 handle_iq_time202(conn, from, id, xmldata); |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1681 return; |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1682 } |
2faf179166f3
Implement XEP-0202 (Entity Time)
Mikael Berthe <mikael@lilotux.net>
parents:
1268
diff
changeset
|
1683 |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1684 x = xmlnode_get_tag(xmldata, "query"); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1685 ns = xmlnode_get_attrib(x, "xmlns"); |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1686 if (ns && !strcmp(ns, NS_DISCO_INFO)) { |
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1687 handle_iq_disco_info(conn, from, id, xmldata); |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1688 } else if (ns && !strcmp(ns, NS_DISCO_ITEMS)) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1689 handle_iq_disco_items(conn, from, id, xmldata); |
995
c89e7993c4d9
Answer IQ disco#info queries
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1690 } else if (ns && !strcmp(ns, NS_VERSION)) { |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1691 handle_iq_version(conn, from, id, xmldata); |
1261
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1692 } else if (ns && !strcmp(ns, NS_LAST)) { |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1693 if (!settings_opt_get_int("iq_last_disable") && |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1694 (!settings_opt_get_int("iq_last_disable_when_notavail") || |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1695 jb_getstatus() != notavail)) |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1696 handle_iq_last(conn, from, id, xmldata); |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1697 else |
704adf4df2d0
Send service-unavailable when Last Activity is disabled
Mikael Berthe <mikael@lilotux.net>
parents:
1255
diff
changeset
|
1698 send_iq_not_available(conn, from, xmldata); |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1699 } else if (ns && !strcmp(ns, NS_TIME)) { |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1700 handle_iq_time(conn, from, id, xmldata); |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1701 } else { |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1702 iq_not_implemented = TRUE; |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1703 } |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1704 |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1705 if (!iq_not_implemented) |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1706 return; |
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1707 |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1708 send_iq_not_implemented(conn, from, xmldata); |
31 | 1709 } |
1710 | |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1711 static void handle_iq_set(jconn conn, char *from, xmlnode xmldata) |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1712 { |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1713 const char *id, *ns; |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1714 xmlnode x; |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1715 guint iq_not_implemented = FALSE; |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
1716 |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
1717 id = xmlnode_get_attrib(xmldata, "id"); |
607 | 1718 if (!id) |
1719 scr_LogPrint(LPRINT_LOG, "IQ set stanza with no ID..."); | |
1720 | |
1721 x = xmlnode_get_tag(xmldata, "query"); | |
1722 ns = xmlnode_get_attrib(x, "xmlns"); | |
1723 if (ns && !strcmp(ns, NS_ROSTER)) { | |
1724 handle_iq_roster(x); | |
1725 } else { | |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1726 x = xmlnode_get_tag(xmldata, "command"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1727 ns = xmlnode_get_attrib(x, "xmlns"); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1728 if (ns && !strcmp(ns, NS_COMMANDS)) { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1729 handle_iq_commands(conn, from, id, xmldata); |
1492
563ba5a861ae
Improve last ad-hoc fix
Mikael Berthe <mikael@lilotux.net>
parents:
1491
diff
changeset
|
1730 return; |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1731 } else { |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1732 iq_not_implemented = TRUE; |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1733 } |
607 | 1734 } |
1735 | |
595
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
1736 if (!id) return; |
0c1d37300862
IQ: send feature-not-implemented error stanzas
Mikael Berthe <mikael@lilotux.net>
parents:
582
diff
changeset
|
1737 |
619
44ddf9bec3a5
Answer IQ:version & IQ:time requests
Mikael Berthe <mikael@lilotux.net>
parents:
613
diff
changeset
|
1738 if (!iq_not_implemented) { |
607 | 1739 x = xmlnode_new_tag("iq"); |
1740 xmlnode_put_attrib(x, "to", xmlnode_get_attrib(xmldata, "from")); | |
1741 xmlnode_put_attrib(x, "type", "result"); | |
1742 xmlnode_put_attrib(x, "id", id); | |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1743 jab_send(conn, x); |
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1744 xmlnode_free(x); |
607 | 1745 } else { |
1158
c30c315dc447
XEP-0146 support (Remote Controlling Clients)
misc@mandriva.org
parents:
1134
diff
changeset
|
1746 send_iq_not_implemented(conn, from, xmldata); |
607 | 1747 } |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1748 } |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1749 |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1750 void handle_packet_iq(jconn conn, char *type, char *from, xmlnode xmldata) |
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1751 { |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1752 if (!type) |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1753 return; |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1754 |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1755 if (!strcmp(type, "result")) { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1756 handle_iq_result(conn, from, xmldata); |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1757 } else if (!strcmp(type, "get")) { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1758 handle_iq_get(conn, from, xmldata); |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1759 } else if (!strcmp(type, "set")) { |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1760 handle_iq_set(conn, from, xmldata); |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1761 } else if (!strcmp(type, TMSG_ERROR)) { |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
1762 // Display a message only if the error isn't caught by a callback. |
577
5c6d364130ee
Move IQ Jabber stuff to a separate file
Mikael Berthe <mikael@lilotux.net>
parents:
576
diff
changeset
|
1763 xmlnode x = xmlnode_get_tag(xmldata, TMSG_ERROR); |
1213
4a7db2870685
Improve Private Storage detection.
Mikael Berthe <mikael@lilotux.net>
parents:
1205
diff
changeset
|
1764 if (iqs_callback(xmlnode_get_attrib(xmldata, "id"), x, IQS_CONTEXT_ERROR)) |
547
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1765 display_server_error(x); |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1766 } |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1767 } |
1df26ff0ed8c
Break packethandler() out
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
1768 |
1008
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1769 // send_storage_bookmarks() |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1770 // Send the current bookmarks node to update the server. |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1771 // Note: the sender should check we're online. |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1772 void send_storage_bookmarks(void) |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1773 { |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1774 eviqs *iqn; |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1775 |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1776 if (!bookmarks) return; |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1777 |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1778 iqn = iqs_new(JPACKET__SET, NS_PRIVATE, "storage", IQS_DEFAULT_TIMEOUT); |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1779 xmlnode_insert_node(xmlnode_get_tag(iqn->xmldata, "query"), bookmarks); |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1780 |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1781 jab_send(jc, iqn->xmldata); |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1782 iqs_del(iqn->id); // XXX |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1783 } |
bbf53cd43fbb
Functions to update room bookmarks
Mikael Berthe <mikael@lilotux.net>
parents:
1006
diff
changeset
|
1784 |
1016 | 1785 // send_storage_rosternotes() |
1786 // Send the current rosternotes node to update the server. | |
1787 // Note: the sender should check we're online. | |
1788 void send_storage_rosternotes(void) | |
1789 { | |
1790 eviqs *iqn; | |
1791 | |
1792 if (!rosternotes) return; | |
1793 | |
1794 iqn = iqs_new(JPACKET__SET, NS_PRIVATE, "storage", IQS_DEFAULT_TIMEOUT); | |
1795 xmlnode_insert_node(xmlnode_get_tag(iqn->xmldata, "query"), rosternotes); | |
1796 | |
1797 jab_send(jc, iqn->xmldata); | |
1798 iqs_del(iqn->id); // XXX | |
1799 } | |
1800 | |
580 | 1801 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |