comparison mcabber/mcabber/xmpp_iqrequest.c @ 2017:87049d55e34f

Fix /request time /request time was still using Legacy Entity Time (XEP-90). This patch makes mcabber use XEP-202 for queries; mcabber still answers to both current and legacy queries.
author Mikael Berthe <mikael@lilotux.net>
date Sat, 28 Jul 2012 14:40:50 +0200
parents aa7e03c35488
children 1210a22726d3
comparison
equal deleted inserted replaced
2016:e9b6e168a45e 2017:87049d55e34f
52 { 52 {
53 const gchar *xmlns; 53 const gchar *xmlns;
54 const gchar *querytag; 54 const gchar *querytag;
55 LmHandleMessageFunction handler; 55 LmHandleMessageFunction handler;
56 } iq_request_handlers[] = { 56 } iq_request_handlers[] = {
57 {NS_ROSTER, "query", &cb_roster}, 57 {NS_ROSTER, "query", &cb_roster},
58 {NS_VERSION,"query", &cb_version}, 58 {NS_VERSION, "query", &cb_version},
59 {NS_TIME, "query", &cb_time}, 59 {NS_XMPP_TIME,"time", &cb_time},
60 {NS_LAST, "query", &cb_last}, 60 {NS_LAST, "query", &cb_last},
61 {NS_PING, "ping", &cb_ping}, 61 {NS_PING, "ping", &cb_ping},
62 {NS_VCARD, "vCard", &cb_vcard}, 62 {NS_VCARD, "vCard", &cb_vcard},
63 {NULL, NULL, NULL} 63 {NULL, NULL, NULL}
64 }; 64 };
65 65
66 // Enum for vCard attributes 66 // Enum for vCard attributes
67 enum vcard_attr { 67 enum vcard_attr {
144 GError *error = NULL; 144 GError *error = NULL;
145 int i; 145 int i;
146 146
147 iq = lm_message_new_with_sub_type(fulljid, LM_MESSAGE_TYPE_IQ, 147 iq = lm_message_new_with_sub_type(fulljid, LM_MESSAGE_TYPE_IQ,
148 LM_MESSAGE_SUB_TYPE_GET); 148 LM_MESSAGE_SUB_TYPE_GET);
149 for (i = 0; strcmp(iq_request_handlers[i].xmlns, xmlns) != 0 ; ++i) 149 for (i = 0; iq_request_handlers[i].xmlns &&
150 strcmp(iq_request_handlers[i].xmlns, xmlns) != 0 ; ++i)
150 ; 151 ;
151 query = lm_message_node_add_child(iq->node, 152 query = lm_message_node_add_child(iq->node,
152 iq_request_handlers[i].querytag, 153 iq_request_handlers[i].querytag,
153 NULL); 154 NULL);
154 lm_message_node_set_attribute(query, "xmlns", xmlns); 155 lm_message_node_set_attribute(query, "xmlns", xmlns);
286 display_server_error(lm_message_node_get_child(m->node, "error"), NULL); 287 display_server_error(lm_message_node_get_child(m->node, "error"), NULL);
287 return LM_HANDLER_RESULT_REMOVE_MESSAGE; 288 return LM_HANDLER_RESULT_REMOVE_MESSAGE;
288 } 289 }
289 290
290 // Check message contents 291 // Check message contents
291 ansqry = lm_message_node_get_child(m->node, "query"); 292 ansqry = lm_message_node_get_child(m->node, "time");
292 if (!ansqry) { 293 if (!ansqry) {
293 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:time result from <%s>!", bjid); 294 scr_LogPrint(LPRINT_LOGNORM, "Invalid IQ:time result from <%s>!", bjid);
294 return LM_HANDLER_RESULT_REMOVE_MESSAGE; 295 return LM_HANDLER_RESULT_REMOVE_MESSAGE;
295 } 296 }
296 297
310 buf = g_strdup_printf("UTC: %s", p); 311 buf = g_strdup_printf("UTC: %s", p);
311 scr_WriteIncomingMessage(bjid, buf, 312 scr_WriteIncomingMessage(bjid, buf,
312 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); 313 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0);
313 g_free(buf); 314 g_free(buf);
314 } 315 }
315 p = lm_message_node_get_child_value(ansqry, "tz"); 316 p = lm_message_node_get_child_value(ansqry, "tzo");
316 if (p && *p) { 317 if (p && *p) {
317 buf = g_strdup_printf("TZ: %s", p); 318 buf = g_strdup_printf("TZ: %s", p);
318 scr_WriteIncomingMessage(bjid, buf, 319 scr_WriteIncomingMessage(bjid, buf,
319 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0); 320 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0);
320 g_free(buf); 321 g_free(buf);