aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/iq.c
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/jabber/iq.c')
-rw-r--r--protocols/jabber/iq.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c
index 2fa418fe..8518439e 100644
--- a/protocols/jabber/iq.c
+++ b/protocols/jabber/iq.c
@@ -1058,3 +1058,62 @@ static xt_status jabber_iq_carbons_response(struct im_connection *ic,
return XT_HANDLED;
}
+
+xt_status jabber_iq_disco_muc_response(struct im_connection *ic, struct xt_node *node, struct xt_node *orig);
+
+int jabber_iq_disco_muc(struct im_connection *ic, const char *muc_server)
+{
+ struct xt_node *node;
+ int st;
+
+ node = xt_new_node("query", NULL, NULL);
+ xt_add_attr(node, "xmlns", XMLNS_DISCO_ITEMS);
+ node = jabber_make_packet("iq", "get", (char *) muc_server, node);
+
+ jabber_cache_add(ic, node, jabber_iq_disco_muc_response);
+ st = jabber_write_packet(ic, node);
+
+ return st;
+}
+
+xt_status jabber_iq_disco_muc_response(struct im_connection *ic, struct xt_node *node, struct xt_node *orig)
+{
+ struct xt_node *query, *c;
+ struct jabber_error *err;
+ GSList *rooms = NULL;
+
+ if ((err = jabber_error_parse(xt_find_node(node->children, "error"), XMLNS_STANZA_ERROR))) {
+ imcb_error(ic, "The server replied with an error: %s%s%s",
+ err->code, err->text ? ": " : "", err->text ? err->text : "");
+ jabber_error_free(err);
+ return XT_HANDLED;
+ }
+
+ if (!(query = xt_find_node(node->children, "query"))) {
+ imcb_error(ic, "Received incomplete MUC list reply");
+ return XT_HANDLED;
+ }
+
+ c = query->children;
+ while ((c = xt_find_node(c, "item"))) {
+ char *jid = xt_find_attr(c, "jid");
+
+ if (!jid || !strchr(jid, '@')) {
+ c = c->next;
+ continue;
+ }
+
+ bee_chat_info_t *ci = g_new(bee_chat_info_t, 1);
+ ci->title = g_strdup(xt_find_attr(c, "jid"));
+ ci->topic = g_strdup(xt_find_attr(c, "name"));
+ rooms = g_slist_prepend(rooms, ci);
+
+ c = c->next;
+ }
+
+ imcb_chat_list_free(ic);
+ ic->chatlist = g_slist_reverse(rooms);
+ imcb_chat_list_finish(ic);
+
+ return XT_HANDLED;
+}
id='n201' href='#n201'>201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294