Changeset 0e4c3dd
- Timestamp:
- 2015-02-21T06:18:21Z (10 years ago)
- Children:
- 89db90e
- Parents:
- 59c1fe7
- Location:
- protocols/jabber
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/Makefile
r59c1fe7 r0e4c3dd 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
r59c1fe7 r0e4c3dd 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) … … 861 860 struct xt_node *node, struct xt_node *orig); 862 861 863 staticint jabber_iq_disco_server(struct im_connection *ic)862 int jabber_iq_disco_server(struct im_connection *ic) 864 863 { 865 864 struct xt_node *node, *iq; -
protocols/jabber/jabber.h
r59c1fe7 r0e4c3dd 250 250 #define XMLNS_IBB "http://jabber.org/protocol/ibb" /* XEP-0047 */ 251 251 252 /* Hipchat protocol extensions*/ 253 #define XMLNS_HIPCHAT "http://hipchat.com" 254 #define XMLNS_HIPCHAT_PROFILE "http://hipchat.com/protocol/profile" 255 #define XMLNS_HIPCHAT_MUC "http://hipchat.com/protocol/muc#room" 256 252 257 /* jabber.c */ 253 258 void jabber_connect(struct im_connection *ic); … … 259 264 int jabber_get_roster(struct im_connection *ic); 260 265 int jabber_get_vcard(struct im_connection *ic, char *bare_jid); 266 int jabber_iq_disco_muc(struct im_connection *ic, char *muc_server); 261 267 int jabber_add_to_roster(struct im_connection *ic, const char *handle, const char *name, const char *group); 262 268 int jabber_remove_from_roster(struct im_connection *ic, char *handle); … … 264 270 xt_status jabber_iq_query_server(struct im_connection *ic, char *jid, char *xmlns); 265 271 void jabber_iq_version_send(struct im_connection *ic, struct jabber_buddy *bud, void *data); 272 int jabber_iq_disco_server(struct im_connection *ic); 266 273 267 274 /* si.c */ … … 357 364 void jabber_chat_invite(struct groupchat *c, char *who, char *message); 358 365 366 /* hipchat.c */ 367 int jabber_get_hipchat_profile(struct im_connection *ic); 368 xt_status jabber_parse_hipchat_profile(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 369 xt_status hipchat_handle_success(struct im_connection *ic, struct xt_node *node); 370 xt_status jabber_parse_muc_list(struct im_connection *ic, struct xt_node *node, struct xt_node *orig); 371 359 372 #endif -
protocols/jabber/sasl.c
r59c1fe7 r0e4c3dd 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->subproto == JSUB_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->subproto == JSUB_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.