- Timestamp:
- 2015-04-28T13:47:48Z (10 years ago)
- Branches:
- master
- Children:
- 70ec7ab, 9ed8175
- Parents:
- 1493c4b
- git-author:
- dequis <dx@…> (21-02-15 06:18:21)
- git-committer:
- dequis <dx@…> (28-04-15 13:47:48)
- Location:
- protocols/jabber
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/Makefile
r1493c4b r40cfbc5 13 13 14 14 # [SH] Program variables 15 objects = conference.o io.o iq.o jabber.o jabber_util.o message.o presence.o s5bytestream.o sasl.o si.o 15 objects = conference.o io.o iq.o jabber.o jabber_util.o message.o presence.o s5bytestream.o sasl.o si.o hipchat.o 16 16 17 17 LFLAGS += -r -
protocols/jabber/iq.c
r1493c4b r40cfbc5 27 27 static xt_status jabber_parse_roster(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 28 28 static xt_status jabber_iq_display_vcard(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 29 static int jabber_iq_disco_server(struct im_connection *ic);30 29 31 30 xt_status jabber_pkt_iq(struct xt_node *node, gpointer data) … … 374 373 static xt_status jabber_parse_roster(struct im_connection *ic, struct xt_node *node, struct xt_node *orig) 375 374 { 375 struct jabber_data *jd = ic->proto_data; 376 376 struct xt_node *query, *c; 377 377 int initial = (orig != NULL); … … 388 388 char *name = xt_find_attr(c, "name"); 389 389 char *sub = xt_find_attr(c, "subscription"); 390 char *mention_name = xt_find_attr(c, "mention_name"); 390 391 391 392 if (jid && sub) { … … 396 397 if (name) { 397 398 imcb_rename_buddy(ic, jid, name); 399 } 400 401 /* This could also be used to set the full name as nick for fb/gtalk, 402 * but i'm keeping the old (ugly?) default behavior just to be safe */ 403 if (mention_name && (jd->flags & JFLAG_HIPCHAT)) { 404 imcb_buddy_nick_hint(ic, jid, mention_name); 398 405 } 399 406 } else if (strcmp(sub, "remove") == 0) { … … 855 862 struct xt_node *node, struct xt_node *orig); 856 863 857 staticint jabber_iq_disco_server(struct im_connection *ic)864 int jabber_iq_disco_server(struct im_connection *ic) 858 865 { 859 866 struct xt_node *node, *iq; -
protocols/jabber/jabber.h
r1493c4b r40cfbc5 236 236 #define XMLNS_IBB "http://jabber.org/protocol/ibb" /* XEP-0047 */ 237 237 238 /* Hipchat protocol extensions*/ 239 #define XMLNS_HIPCHAT "http://hipchat.com" 240 #define XMLNS_HIPCHAT_PROFILE "http://hipchat.com/protocol/profile" 241 238 242 /* jabber.c */ 239 243 void jabber_connect(struct im_connection *ic); … … 250 254 xt_status jabber_iq_query_server(struct im_connection *ic, char *jid, char *xmlns); 251 255 void jabber_iq_version_send(struct im_connection *ic, struct jabber_buddy *bud, void *data); 256 int jabber_iq_disco_server(struct im_connection *ic); 252 257 253 258 /* si.c */ … … 342 347 void jabber_chat_invite(struct groupchat *c, char *who, char *message); 343 348 349 /* hipchat.c */ 350 int jabber_get_hipchat_profile(struct im_connection *ic); 351 xt_status jabber_parse_hipchat_profile(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 352 xt_status hipchat_handle_success(struct im_connection *ic, struct xt_node *node); 353 344 354 #endif -
protocols/jabber/sasl.c
r1493c4b r40cfbc5 55 55 char *s; 56 56 int sup_plain = 0, sup_digest = 0, sup_gtalk = 0, sup_fb = 0; 57 int want_oauth = FALSE ;57 int want_oauth = FALSE, want_hipchat = FALSE; 58 58 GString *mechs; 59 59 … … 75 75 76 76 want_oauth = set_getbool(&ic->acc->set, "oauth"); 77 want_hipchat = (jd->flags & JFLAG_HIPCHAT); 77 78 78 79 mechs = g_string_new(""); … … 111 112 112 113 reply = xt_new_node("auth", NULL, NULL); 113 xt_add_attr(reply, "xmlns", XMLNS_SASL); 114 if (!want_hipchat) { 115 xt_add_attr(reply, "xmlns", XMLNS_SASL); 116 } else { 117 xt_add_attr(reply, "xmlns", XMLNS_HIPCHAT); 118 } 114 119 115 120 if (sup_gtalk && want_oauth) { … … 143 148 } else if (sup_plain) { 144 149 int len; 145 146 xt_add_attr(reply, "mechanism", "PLAIN"); 150 GString *gs; 151 char *username; 152 153 if (!want_hipchat) { 154 xt_add_attr(reply, "mechanism", "PLAIN"); 155 username = jd->username; 156 } else { 157 username = jd->me; 158 } 159 160 /* set an arbitrary initial size to avoid reallocations */ 161 gs = g_string_sized_new(128); 147 162 148 163 /* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */ 149 len = strlen(jd->username) + strlen(ic->acc->pass) + 2; 150 s = g_malloc(len + 1); 151 s[0] = 0; 152 strcpy(s + 1, jd->username); 153 strcpy(s + 2 + strlen(jd->username), ic->acc->pass); 164 g_string_append_c(gs, '\0'); 165 g_string_append(gs, username); 166 g_string_append_c(gs, '\0'); 167 g_string_append(gs, ic->acc->pass); 168 if (want_hipchat) { 169 /* Hipchat's variation adds \0resource at the end */ 170 g_string_append_c(gs, '\0'); 171 g_string_append(gs, set_getstr(&ic->acc->set, "resource")); 172 } 173 174 len = gs->len; 175 s = g_string_free(gs, FALSE); 176 154 177 reply->text = base64_encode((unsigned char *) s, len); 155 178 reply->text_len = strlen(reply->text); … … 397 420 imcb_log(ic, "Authentication finished"); 398 421 jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART; 422 423 if (jd->flags & JFLAG_HIPCHAT) { 424 return hipchat_handle_success(ic, node); 425 } 399 426 } else if (strcmp(node->name, "failure") == 0) { 400 427 imcb_error(ic, "Authentication failure");
Note: See TracChangeset
for help on using the changeset viewer.