31 #include "compl.h" |
31 #include "compl.h" |
32 #include "xmpp_defines.h" |
32 #include "xmpp_defines.h" |
33 #include "screen.h" |
33 #include "screen.h" |
34 #include "hbuf.h" |
34 #include "hbuf.h" |
35 |
35 |
|
36 static GSList *disco_handlers = NULL; |
|
37 static guint disco_cid = 0; |
|
38 |
36 static LmHandlerResult disco_handler (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, gpointer udata) |
39 static LmHandlerResult disco_handler (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, gpointer udata) |
37 { |
40 { |
38 int info_request = (int) udata; |
41 int info_request = (int) udata; |
|
42 |
|
43 disco_handlers = g_slist_remove (disco_handlers, handler); |
39 |
44 |
40 switch (lm_message_get_sub_type (message)) { |
45 switch (lm_message_get_sub_type (message)) { |
41 case LM_MESSAGE_SUB_TYPE_RESULT: |
46 case LM_MESSAGE_SUB_TYPE_RESULT: |
42 |
47 |
43 { |
48 { |
82 |
87 |
83 g_string_append_printf (features, "\n [%s]", var ? var : "none"); |
88 g_string_append_printf (features, "\n [%s]", var ? var : "none"); |
84 } |
89 } |
85 } |
90 } |
86 |
91 |
87 if (identities->str) |
92 if (identities->len) |
88 g_string_append_printf (info, "\n Identities:%s", identities->str); |
93 g_string_append_printf (info, "\n Identities:%s", identities->str); |
89 if (features->str) |
94 if (features->len) |
90 g_string_append_printf (info, "\n Features:%s", features->str); |
95 g_string_append_printf (info, "\n Features:%s", features->str); |
91 |
96 |
92 g_string_free (identities, TRUE); |
97 g_string_free (identities, TRUE); |
93 g_string_free (features, TRUE); |
98 g_string_free (features, TRUE); |
94 |
99 |
204 lm_message_node_set_attribute (node, "node", dnode); |
209 lm_message_node_set_attribute (node, "node", dnode); |
205 } |
210 } |
206 |
211 |
207 lm_connection_send_with_reply (lconnection, request, handler, NULL); |
212 lm_connection_send_with_reply (lconnection, request, handler, NULL); |
208 |
213 |
|
214 lm_message_handler_unref (handler); |
|
215 lm_message_unref (request); |
|
216 g_free (dnode); |
209 g_free (to); |
217 g_free (to); |
210 g_free (dnode); |
|
211 } |
218 } |
212 } |
219 } |
213 |
220 |
214 const gchar *g_module_check_init(GModule *module) |
221 const gchar *g_module_check_init(GModule *module) |
215 { |
222 { |
216 // TODO completion |
223 disco_handlers = NULL; |
217 |
224 |
218 cmd_add ("disco", "", 0, COMPL_JID, do_disco, NULL); |
225 // completion |
|
226 disco_cid = compl_new_category (); |
|
227 if (disco_cid) { |
|
228 compl_add_category_word (disco_cid, "info"); |
|
229 compl_add_category_word (disco_cid, "items"); |
|
230 } |
|
231 |
|
232 // command |
|
233 cmd_add ("disco", "", disco_cid, COMPL_JID, do_disco, NULL); |
|
234 |
219 return NULL; |
235 return NULL; |
220 } |
236 } |
221 |
237 |
222 void g_module_unload(GModule *module) |
238 void g_module_unload(GModule *module) |
223 { |
239 { |
|
240 GSList *hel; |
|
241 |
|
242 // let's hope, that after invalidation, lm will remove and free unreffed by us handler |
|
243 for (hel = disco_handlers; hel; hel = hel->next) { |
|
244 LmMessageHandler *handler = (LmMessageHandler *) hel->data; |
|
245 lm_message_handler_invalidate (handler); |
|
246 } |
|
247 |
|
248 // free list |
|
249 g_slist_free (disco_handlers); |
|
250 disco_handlers = NULL; |
|
251 |
|
252 // command |
224 cmd_del ("disco"); |
253 cmd_del ("disco"); |
|
254 |
|
255 // completion |
|
256 if (disco_cid) |
|
257 compl_del_category (disco_cid); |
225 } |
258 } |
226 |
259 |
227 /* vim: se ts=4: */ |
260 /* vim: se ts=4: */ |