Changes in protocols/jabber/message.c [5ebff60:d11ccbf]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/message.c
r5ebff60 rd11ccbf 24 24 #include "jabber.h" 25 25 26 xt_status jabber_pkt_message(struct xt_node *node, gpointer data)26 static xt_status jabber_pkt_message_normal(struct xt_node *node, gpointer data, gboolean carbons_sent) 27 27 { 28 28 struct im_connection *ic = data; 29 char *from = xt_find_attr(node, "from"); 29 struct jabber_data *jd = ic->proto_data; 30 char *from = xt_find_attr(node, carbons_sent ? "to" : "from"); 30 31 char *type = xt_find_attr(node, "type"); 31 32 char *id = xt_find_attr(node, "id"); … … 37 38 if (!from) { 38 39 return XT_HANDLED; /* Consider this packet corrupted. */ 39 40 } 41 if (request && id) { 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) { 42 54 /* Send a message receipt (XEP-0184), looking like this: 43 * <message 44 * from='kingrichard@royalty.england.lit/throne' 45 * id='bi29sg183b4v' 46 * to='northumberland@shakespeare.lit/westminster'> 55 * <message from='...' id='...' to='...'> 47 56 * <received xmlns='urn:xmpp:receipts' id='richard2-4.1.247'/> 48 * </message> */ 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 */ 49 62 struct xt_node *received, *receipt; 50 63 … … 127 140 if (fullmsg->len > 0) { 128 141 imcb_buddy_msg(ic, from, fullmsg->str, 129 0, jabber_get_timestamp(node));142 carbons_sent ? OPT_SELFMESSAGE : 0, jabber_get_timestamp(node)); 130 143 } 131 144 if (room) { … … 136 149 137 150 /* Handling of incoming typing notifications. */ 138 if (bud == NULL) { 139 /* Can't handle these for unknown buddies. */ 151 if (bud == NULL || carbons_sent) { 152 /* Can't handle these for unknown buddies. 153 And ignore them if it's just carbons */ 140 154 } else if (xt_find_node(node->children, "composing")) { 141 155 bud->flags |= JBFLAG_DOES_XEP85; 142 156 imcb_buddy_typing(ic, from, OPT_TYPING); 143 157 } 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)) { 158 else if (xt_find_node(node->children, "active")) { 146 159 bud->flags |= JBFLAG_DOES_XEP85; 147 imcb_buddy_typing(ic, from, 0); 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 } 148 165 } else if (xt_find_node(node->children, "paused")) { 149 166 bud->flags |= JBFLAG_DOES_XEP85; … … 158 175 return XT_HANDLED; 159 176 } 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.