Changes in protocols/jabber/message.c [d11ccbf:5ebff60]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/message.c
rd11ccbf r5ebff60 24 24 #include "jabber.h" 25 25 26 static xt_status jabber_pkt_message_normal(struct xt_node *node, gpointer data, gboolean carbons_sent)26 xt_status jabber_pkt_message(struct xt_node *node, gpointer data) 27 27 { 28 28 struct im_connection *ic = data; 29 struct jabber_data *jd = ic->proto_data; 30 char *from = xt_find_attr(node, carbons_sent ? "to" : "from"); 29 char *from = xt_find_attr(node, "from"); 31 30 char *type = xt_find_attr(node, "type"); 32 31 char *id = xt_find_attr(node, "id"); … … 38 37 if (!from) { 39 38 return XT_HANDLED; /* Consider this packet corrupted. */ 39 40 40 } 41 42 /* try to detect hipchat's own version of self-messages */ 43 if (jd->flags & JFLAG_HIPCHAT) { 44 struct xt_node *c; 45 46 if ((c = xt_find_node_by_attr(node->children, "delay", "xmlns", XMLNS_DELAY)) && 47 (s = xt_find_attr(c, "from_jid")) && 48 jabber_compare_jid(s, jd->me)) { 49 carbons_sent = TRUE; 50 } 51 } 52 53 if (request && id && g_strcmp0(type, "groupchat") != 0 && !carbons_sent) { 41 if (request && id) { 54 42 /* Send a message receipt (XEP-0184), looking like this: 55 * <message from='...' id='...' to='...'> 43 * <message 44 * from='kingrichard@royalty.england.lit/throne' 45 * id='bi29sg183b4v' 46 * to='northumberland@shakespeare.lit/westminster'> 56 47 * <received xmlns='urn:xmpp:receipts' id='richard2-4.1.247'/> 57 * </message> 58 * 59 * MUC messages are excluded, since receipts aren't supposed to be sent over MUCs 60 * (XEP-0184 section 5.3) and replying to those may result in 'forbidden' errors. 61 */ 48 * </message> */ 62 49 struct xt_node *received, *receipt; 63 50 … … 140 127 if (fullmsg->len > 0) { 141 128 imcb_buddy_msg(ic, from, fullmsg->str, 142 carbons_sent ? OPT_SELFMESSAGE :0, jabber_get_timestamp(node));129 0, jabber_get_timestamp(node)); 143 130 } 144 131 if (room) { … … 149 136 150 137 /* Handling of incoming typing notifications. */ 151 if (bud == NULL || carbons_sent) { 152 /* Can't handle these for unknown buddies. 153 And ignore them if it's just carbons */ 138 if (bud == NULL) { 139 /* Can't handle these for unknown buddies. */ 154 140 } else if (xt_find_node(node->children, "composing")) { 155 141 bud->flags |= JBFLAG_DOES_XEP85; 156 142 imcb_buddy_typing(ic, from, OPT_TYPING); 157 143 } 158 else if (xt_find_node(node->children, "active")) { 144 /* No need to send a "stopped typing" signal when there's a message. */ 145 else if (xt_find_node(node->children, "active") && (body == NULL)) { 159 146 bud->flags |= JBFLAG_DOES_XEP85; 160 161 /* No need to send a "stopped typing" signal when there's a message. */ 162 if (body == NULL) { 163 imcb_buddy_typing(ic, from, 0); 164 } 147 imcb_buddy_typing(ic, from, 0); 165 148 } else if (xt_find_node(node->children, "paused")) { 166 149 bud->flags |= JBFLAG_DOES_XEP85; … … 175 158 return XT_HANDLED; 176 159 } 177 178 static xt_status jabber_carbons_message(struct xt_node *node, gpointer data)179 {180 struct im_connection *ic = data;181 struct xt_node *wrap, *fwd, *msg;182 gboolean carbons_sent;183 184 if ((wrap = xt_find_node(node->children, "received"))) {185 carbons_sent = FALSE;186 } else if ((wrap = xt_find_node(node->children, "sent"))) {187 carbons_sent = TRUE;188 }189 190 if (wrap == NULL || g_strcmp0(xt_find_attr(wrap, "xmlns"), XMLNS_CARBONS) != 0) {191 return XT_NEXT;192 }193 194 if (!(fwd = xt_find_node(wrap->children, "forwarded")) ||195 (g_strcmp0(xt_find_attr(fwd, "xmlns"), XMLNS_FORWARDING) != 0) ||196 !(msg = xt_find_node(fwd->children, "message"))) {197 imcb_log(ic, "Error: Invalid carbons message received");198 return XT_ABORT;199 }200 201 return jabber_pkt_message_normal(msg, data, carbons_sent);202 }203 204 xt_status jabber_pkt_message(struct xt_node *node, gpointer data)205 {206 struct im_connection *ic = data;207 struct jabber_data *jd = ic->proto_data;208 char *from = xt_find_attr(node, "from");209 210 if (jabber_compare_jid(jd->me, from)) { /* Probably a Carbons message */211 xt_status st = jabber_carbons_message(node, data);212 if (st == XT_HANDLED || st == XT_ABORT) {213 return st;214 }215 }216 return jabber_pkt_message_normal(node, data, FALSE);217 }
Note: See TracChangeset
for help on using the changeset viewer.