1 /* |
1 |
2 * disco.c -- Service discovery requests |
2 /* Copyright 2009 Myhailo Danylenko |
3 * |
3 * |
4 * Copyrigth (C) 2009 Myhailo Danylenko <isbear@ukrpost.net> |
4 * Service discovery requests |
5 * |
5 * |
6 * This program is free software; you can redistribute it and/or modify |
6 * This file is part of mcabber-disco |
|
7 * |
|
8 * mcabber-disco is free software: you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by |
9 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation; either version 2 of the License, or (at |
10 * the Free Software Foundation, either version 2 of the License, or |
9 * your option) any later version. |
11 * (at your option) any later version. |
10 * |
12 * |
11 * This program is distributed in the hope that it will be useful, but |
13 * This program is distributed in the hope that it will be useful, |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 * General Public License for more details. |
16 * GNU General Public License for more details. |
15 * |
17 * |
16 * You should have received a copy of the GNU General Public License |
18 * You should have received a copy of the GNU General Public License |
17 * along with this program; if not, write to the Free Software |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
19 * USA |
|
20 */ |
|
21 |
20 |
22 #include <glib.h> |
21 #include <glib.h> |
23 #include <gmodule.h> |
22 #include <gmodule.h> |
24 #include <loudmouth/loudmouth.h> |
23 #include <loudmouth/loudmouth.h> |
25 #include <string.h> |
24 #include <string.h> |
159 return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
158 return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
160 } |
159 } |
161 |
160 |
162 static LmHandlerResult disco_info_handler (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, gpointer udata) |
161 static LmHandlerResult disco_info_handler (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, gpointer udata) |
163 { |
162 { |
164 return disco_handler (message, TRUE); |
163 return disco_handler (message, TRUE); |
165 } |
164 } |
166 |
165 |
167 static LmHandlerResult disco_items_handler (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, gpointer udata) |
166 static LmHandlerResult disco_items_handler (LmMessageHandler *handler, LmConnection *connection, LmMessage *message, gpointer udata) |
168 { |
167 { |
169 return disco_handler (message, FALSE); |
168 return disco_handler (message, FALSE); |
170 } |
169 } |
171 |
170 |
172 static void do_disco (char *arg) |
171 static void do_disco (char *arg) |
173 { |
172 { |
174 char **args = split_arg (arg, 3, 0); |
173 char **args = split_arg (arg, 3, 0); |
215 lm_message_node_set_attribute (node, "xmlns", info ? NS_DISCO_INFO : NS_DISCO_ITEMS); |
214 lm_message_node_set_attribute (node, "xmlns", info ? NS_DISCO_INFO : NS_DISCO_ITEMS); |
216 if (dnode) |
215 if (dnode) |
217 lm_message_node_set_attribute (node, "node", dnode); |
216 lm_message_node_set_attribute (node, "node", dnode); |
218 } |
217 } |
219 |
218 |
220 lm_connection_send_with_reply (lconnection, request, info ? disco_info_reply_handler : disco_items_reply_handler, NULL); |
219 { |
|
220 GError *error = NULL; |
|
221 |
|
222 lm_connection_send_with_reply (lconnection, request, info ? disco_info_reply_handler : disco_items_reply_handler, &error); |
|
223 |
|
224 if (error) { |
|
225 scr_LogPrint (LPRINT_DEBUG, "disco: Error sending disco request: %s.", error -> message); |
|
226 g_error_free (error); |
|
227 } |
|
228 } |
221 |
229 |
222 lm_message_unref (request); |
230 lm_message_unref (request); |
223 if (dnode) |
231 if (dnode) |
224 g_free (dnode); |
232 g_free (dnode); |
225 if (to) |
233 if (to) |