comparison mcabber/mcabber/xmpp.c @ 1729:e6e89b1d7831

Minor style and header updates
author Mikael Berthe <mikael@lilotux.net>
date Sun, 28 Feb 2010 15:19:27 +0100
parents 15b3834cbe5f
children 860b58a0e8da
comparison
equal deleted inserted replaced
1728:15b3834cbe5f 1729:e6e89b1d7831
1 /* 1 /*
2 * xmpp.c -- Jabber protocol handling 2 * xmpp.c -- Jabber protocol handling
3 * 3 *
4 * Copyright (C) 2008-2009 Frank Zschockelt <mcabber@freakysoft.de> 4 * Copyright (C) 2008-2010 Frank Zschockelt <mcabber@freakysoft.de>
5 * Copyright (C) 2005-2009 Mikael Berthe <mikael@lilotux.net> 5 * Copyright (C) 2005-2010 Mikael Berthe <mikael@lilotux.net>
6 * Parts come from the centericq project: 6 * Parts come from the centericq project:
7 * Copyright (C) 2002-2005 by Konstantin Klyagin <konst@konst.org.ua> 7 * Copyright (C) 2002-2005 by Konstantin Klyagin <konst@konst.org.ua>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
202 lm_connection_send(lconnection, iq, NULL); 202 lm_connection_send(lconnection, iq, NULL);
203 lm_message_unref(iq); 203 lm_message_unref(iq);
204 } 204 }
205 205
206 // Cancel the subscriptions 206 // Cancel the subscriptions
207 xmpp_send_s10n(cleanjid, LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED); //cancel "from" 207 xmpp_send_s10n(cleanjid, LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED); // cancel "from"
208 xmpp_send_s10n(cleanjid, LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE); //cancel "to" 208 xmpp_send_s10n(cleanjid, LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE); // cancel "to"
209 209
210 // Ask for removal from roster 210 // Ask for removal from roster
211 iq = lm_message_new_with_sub_type(NULL, LM_MESSAGE_TYPE_IQ, 211 iq = lm_message_new_with_sub_type(NULL, LM_MESSAGE_TYPE_IQ,
212 LM_MESSAGE_SUB_TYPE_SET); 212 LM_MESSAGE_SUB_TYPE_SET);
213 213
420 if (encrypted) 420 if (encrypted)
421 *encrypted = ENCRYPTED_PGP; 421 *encrypted = ENCRYPTED_PGP;
422 g_free(enc); 422 g_free(enc);
423 } 423 }
424 424
425 //XEP-0184: Message Receipts 425 // XEP-0184: Message Receipts
426 if (sl_buddy && rname && xep184 && 426 if (sl_buddy && rname && xep184 &&
427 caps_has_feature(buddy_resource_getcaps(sl_buddy->data, rname), 427 caps_has_feature(buddy_resource_getcaps(sl_buddy->data, rname),
428 NS_RECEIPTS)) { 428 NS_RECEIPTS)) {
429 lm_message_node_set_attribute 429 lm_message_node_set_attribute
430 (lm_message_node_add_child(x->node, "request", NULL), 430 (lm_message_node_add_child(x->node, "request", NULL),
766 return; 766 return;
767 res_pgpdata = buddy_resource_pgp(sl_buddy->data, rname); 767 res_pgpdata = buddy_resource_pgp(sl_buddy->data, rname);
768 if (!res_pgpdata) 768 if (!res_pgpdata)
769 return; 769 return;
770 770
771 if (!node->name || strcmp(node->name, "x")) //XXX: probably useless 771 if (!node->name || strcmp(node->name, "x")) // XXX: probably useless
772 return; // We expect "<x xmlns='jabber:x:signed'>" 772 return; // We expect "<x xmlns='jabber:x:signed'>"
773 773
774 // Get signature 774 // Get signature
775 p = lm_message_node_get_value(node); 775 p = lm_message_node_get_value(node);
776 if (!p) 776 if (!p)
1264 handle_state_events(from, m->node); 1264 handle_state_events(from, m->node);
1265 } 1265 }
1266 if (from && (body || subject)) 1266 if (from && (body || subject))
1267 gotmessage(mstype, from, body, enc, subject, timestamp, 1267 gotmessage(mstype, from, body, enc, subject, timestamp,
1268 lm_message_node_find_xmlns(m->node, NS_SIGNED)); 1268 lm_message_node_find_xmlns(m->node, NS_SIGNED));
1269 //report received message if message receipt was requested 1269 // Report received message if message receipt was requested
1270 if (lm_message_node_get_child(m->node, "request")) { 1270 if (lm_message_node_get_child(m->node, "request")) {
1271 LmMessage *rcvd = lm_message_new(from, LM_MESSAGE_TYPE_MESSAGE); 1271 LmMessage *rcvd = lm_message_new(from, LM_MESSAGE_TYPE_MESSAGE);
1272 lm_message_node_set_attribute(rcvd->node, "id", lm_message_get_id(m)); 1272 lm_message_node_set_attribute(rcvd->node, "id", lm_message_get_id(m));
1273 lm_message_node_set_attribute 1273 lm_message_node_set_attribute
1274 (lm_message_node_add_child(rcvd->node, "received", NULL), 1274 (lm_message_node_add_child(rcvd->node, "received", NULL),
1573 update_roster = TRUE; 1573 update_roster = TRUE;
1574 g_free(r); 1574 g_free(r);
1575 return LM_HANDLER_RESULT_REMOVE_MESSAGE; 1575 return LM_HANDLER_RESULT_REMOVE_MESSAGE;
1576 } 1576 }
1577 1577
1578 //TODO: Use the enum of loudmouth, when it's included in the header... 1578 // TODO: Use the enum of loudmouth, when it's included in the header...
1579 typedef enum { 1579 typedef enum {
1580 LM_LOG_LEVEL_VERBOSE = 1 << (G_LOG_LEVEL_USER_SHIFT), 1580 LM_LOG_LEVEL_VERBOSE = 1 << (G_LOG_LEVEL_USER_SHIFT),
1581 LM_LOG_LEVEL_NET = 1 << (G_LOG_LEVEL_USER_SHIFT + 1), 1581 LM_LOG_LEVEL_NET = 1 << (G_LOG_LEVEL_USER_SHIFT + 1),
1582 LM_LOG_LEVEL_PARSER = 1 << (G_LOG_LEVEL_USER_SHIFT + 2), 1582 LM_LOG_LEVEL_PARSER = 1 << (G_LOG_LEVEL_USER_SHIFT + 2),
1583 LM_LOG_LEVEL_SSL = 1 << (G_LOG_LEVEL_USER_SHIFT + 3), 1583 LM_LOG_LEVEL_SSL = 1 << (G_LOG_LEVEL_USER_SHIFT + 3),