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