45 void disco_init (void); |
45 void disco_init (void); |
46 void disco_uninit (void); |
46 void disco_uninit (void); |
47 |
47 |
48 #define DESCRIPTION ( "Service discovery requests\nProvides command /disco" ) |
48 #define DESCRIPTION ( "Service discovery requests\nProvides command /disco" ) |
49 |
49 |
50 static module_info_t info_disco_dev = { |
50 module_info_t info_disco = { |
51 .branch = "dev", |
51 .branch = MCABBER_BRANCH, |
52 .api = 20, |
52 .api = MCABBER_API_VERSION, |
53 .version = PROJECT_VERSION, |
53 .version = PROJECT_VERSION, |
54 .description = DESCRIPTION, |
54 .description = DESCRIPTION, |
55 .requires = NULL, |
55 .requires = NULL, |
56 .init = disco_init, |
56 .init = disco_init, |
57 .uninit = disco_uninit, |
57 .uninit = disco_uninit, |
58 .next = NULL, |
58 .next = NULL, |
59 }; |
59 }; |
60 |
60 |
61 module_info_t info_disco_0_10_0 = { |
|
62 .branch = "0.10.0", |
|
63 .api = 1, |
|
64 .version = PROJECT_VERSION, |
|
65 .description = DESCRIPTION, |
|
66 .requires = NULL, |
|
67 .init = disco_init, |
|
68 .uninit = disco_uninit, |
|
69 .next = &info_disco_dev, |
|
70 }; |
|
71 |
|
72 module_info_t info_disco = { |
|
73 .branch = "0.10.1", |
|
74 .api = 1, |
|
75 .version = PROJECT_VERSION, |
|
76 .description = DESCRIPTION, |
|
77 .requires = NULL, |
|
78 .init = disco_init, |
|
79 .uninit = disco_uninit, |
|
80 .next = &info_disco_0_10_0, |
|
81 }; |
|
82 |
|
83 // |
61 // |
84 // private types |
62 // private types |
85 // |
63 // |
86 |
64 |
87 // lm message handler userdata |
65 // lm message handler userdata |
123 static void disco_info_reply_handler_destroy_notify (gpointer data) |
101 static void disco_info_reply_handler_destroy_notify (gpointer data) |
124 { |
102 { |
125 disco_info_reply_handler_t *cb = data; |
103 disco_info_reply_handler_t *cb = data; |
126 if (cb -> notify) |
104 if (cb -> notify) |
127 cb -> notify (cb -> data); |
105 cb -> notify (cb -> data); |
128 g_free (cb); |
106 g_slice_free (disco_info_reply_handler_t, cb); |
129 return; |
107 return; |
130 } |
108 } |
131 |
109 |
132 static void disco_items_reply_handler_destroy_notify (gpointer data) |
110 static void disco_items_reply_handler_destroy_notify (gpointer data) |
133 { |
111 { |
134 disco_items_reply_handler_t *cb = data; |
112 disco_items_reply_handler_t *cb = data; |
135 if (cb -> notify) |
113 if (cb -> notify) |
136 cb -> notify (cb -> data); |
114 cb -> notify (cb -> data); |
137 g_free (cb); |
115 g_slice_free (disco_items_reply_handler_t, cb); |
138 return; |
116 return; |
139 } |
117 } |
140 |
118 |
141 static void disco_handler_destroy_notify (gpointer data) |
119 static void disco_handler_destroy_notify (gpointer data) |
142 { |
120 { |
143 disco_handler_t *cb = data; |
121 disco_handler_t *cb = data; |
144 g_free (cb -> jid); |
122 g_free (cb -> jid); |
145 g_free (cb -> node); |
123 g_free (cb -> node); |
146 g_free (cb); |
124 g_slice_free (disco_handler_t, cb); |
147 return; |
125 return; |
148 } |
126 } |
149 |
127 |
150 // |
128 // |
151 // lm reply handlers |
129 // lm reply handlers |
173 |
151 |
174 // parse request results |
152 // parse request results |
175 if (node->children) |
153 if (node->children) |
176 for (node = node->children; node; node = node->next) |
154 for (node = node->children; node; node = node->next) |
177 if (!strcasecmp (node->name, "identity")) { |
155 if (!strcasecmp (node->name, "identity")) { |
178 disco_identity_t *identity = g_new (disco_identity_t, 1); |
156 disco_identity_t *identity = g_slice_new (disco_identity_t); |
179 |
157 |
180 identity -> category = lm_message_node_get_attribute (node, "category"); |
158 identity -> category = lm_message_node_get_attribute (node, "category"); |
181 identity -> type = lm_message_node_get_attribute (node, "type"); |
159 identity -> type = lm_message_node_get_attribute (node, "type"); |
182 identity -> name = lm_message_node_get_attribute (node, "name"); |
160 identity -> name = lm_message_node_get_attribute (node, "name"); |
183 identity -> reserved = NULL; |
161 identity -> reserved = NULL; |
253 |
231 |
254 // parse request results |
232 // parse request results |
255 if (node->children) |
233 if (node->children) |
256 for (node = node->children; node; node = node->next) |
234 for (node = node->children; node; node = node->next) |
257 if (!strcasecmp (node->name, "item")) { |
235 if (!strcasecmp (node->name, "item")) { |
258 disco_item_t *item = g_new (disco_item_t, 1); |
236 disco_item_t *item = g_slice_new (disco_item_t); |
259 |
237 |
260 item -> name = lm_message_node_get_attribute (node, "name"); |
238 item -> name = lm_message_node_get_attribute (node, "name"); |
261 item -> jid = lm_message_node_get_attribute (node, "jid"); |
239 item -> jid = lm_message_node_get_attribute (node, "jid"); |
262 item -> node = lm_message_node_get_attribute (node, "node"); |
240 item -> node = lm_message_node_get_attribute (node, "node"); |
263 |
241 |
366 lm_message_node_set_attribute (node, "xmlns", NS_DISCO_INFO); |
344 lm_message_node_set_attribute (node, "xmlns", NS_DISCO_INFO); |
367 if (dnode) |
345 if (dnode) |
368 lm_message_node_set_attribute (node, "node", dnode); |
346 lm_message_node_set_attribute (node, "node", dnode); |
369 |
347 |
370 { |
348 { |
371 disco_info_reply_handler_t *cb = g_new (disco_info_reply_handler_t, 1); |
349 disco_info_reply_handler_t *cb = g_slice_new (disco_info_reply_handler_t); |
372 |
350 |
373 lhandler = lm_message_handler_new (disco_info_reply_handler, cb, disco_info_reply_handler_destroy_notify); |
351 lhandler = lm_message_handler_new (disco_info_reply_handler, cb, disco_info_reply_handler_destroy_notify); |
374 |
352 |
375 cb -> handler = handler; |
353 cb -> handler = handler; |
376 cb -> data = userdata; |
354 cb -> data = userdata; |
415 lm_message_node_set_attribute (node, "xmlns", NS_DISCO_ITEMS); |
393 lm_message_node_set_attribute (node, "xmlns", NS_DISCO_ITEMS); |
416 if (dnode) |
394 if (dnode) |
417 lm_message_node_set_attribute (node, "node", dnode); |
395 lm_message_node_set_attribute (node, "node", dnode); |
418 |
396 |
419 { |
397 { |
420 disco_items_reply_handler_t *cb = g_new (disco_items_reply_handler_t, 1); |
398 disco_items_reply_handler_t *cb = g_slice_new (disco_items_reply_handler_t); |
421 |
399 |
422 lhandler = lm_message_handler_new (disco_items_reply_handler, cb, disco_items_reply_handler_destroy_notify); |
400 lhandler = lm_message_handler_new (disco_items_reply_handler, cb, disco_items_reply_handler_destroy_notify); |
423 |
401 |
424 cb -> handler = handler; |
402 cb -> handler = handler; |
425 cb -> data = userdata; |
403 cb -> data = userdata; |