Changeset 399d65a for protocols/jabber/iq.c
- Timestamp:
- 2016-10-17T02:46:33Z (8 years ago)
- Branches:
- master
- Children:
- 4466e3e
- Parents:
- 2906268
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/iq.c
r2906268 r399d65a 1059 1059 return XT_HANDLED; 1060 1060 } 1061 1062 xt_status jabber_iq_disco_muc_response(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 1063 1064 int jabber_iq_disco_muc(struct im_connection *ic, const char *muc_server) 1065 { 1066 struct xt_node *node; 1067 int st; 1068 1069 node = xt_new_node("query", NULL, NULL); 1070 xt_add_attr(node, "xmlns", XMLNS_DISCO_ITEMS); 1071 node = jabber_make_packet("iq", "get", (char *) muc_server, node); 1072 1073 jabber_cache_add(ic, node, jabber_iq_disco_muc_response); 1074 st = jabber_write_packet(ic, node); 1075 1076 return st; 1077 } 1078 1079 xt_status jabber_iq_disco_muc_response(struct im_connection *ic, struct xt_node *node, struct xt_node *orig) 1080 { 1081 struct xt_node *query, *c; 1082 struct jabber_error *err; 1083 GSList *rooms = NULL; 1084 1085 if ((err = jabber_error_parse(xt_find_node(node->children, "error"), XMLNS_STANZA_ERROR))) { 1086 imcb_error(ic, "The server replied with an error: %s%s%s", 1087 err->code, err->text ? ": " : "", err->text ? err->text : ""); 1088 jabber_error_free(err); 1089 return XT_HANDLED; 1090 } 1091 1092 if (!(query = xt_find_node(node->children, "query"))) { 1093 imcb_error(ic, "Received incomplete MUC list reply"); 1094 return XT_HANDLED; 1095 } 1096 1097 c = query->children; 1098 while ((c = xt_find_node(c, "item"))) { 1099 char *jid = xt_find_attr(c, "jid"); 1100 1101 if (!jid || !strchr(jid, '@')) { 1102 c = c->next; 1103 continue; 1104 } 1105 1106 bee_chat_info_t *ci = g_new(bee_chat_info_t, 1); 1107 ci->title = g_strdup(xt_find_attr(c, "jid")); 1108 ci->topic = g_strdup(xt_find_attr(c, "name")); 1109 rooms = g_slist_prepend(rooms, ci); 1110 1111 c = c->next; 1112 } 1113 1114 imcb_chat_list_free(ic); 1115 ic->chatlist = g_slist_reverse(rooms); 1116 imcb_chat_list_finish(ic); 1117 1118 return XT_HANDLED; 1119 }
Note: See TracChangeset
for help on using the changeset viewer.