Changes in / [356e2dd:71074ac]
- Files:
-
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.h
r356e2dd r71074ac 147 147 IRC_CHANNEL_TEMP = 2, /* Erase the channel when the user leaves, 148 148 and don't save it. */ 149 150 /* Show a placeholder of the channel in listings, but don't save it */151 IRC_CHANNEL_KEEP_PLACEHOLDER = 4,152 149 153 150 /* Hack: Set this flag right before jumping into IM when we expect -
irc_channel.c
r356e2dd r71074ac 276 276 if (ic->irc->status & USTATUS_SHUTDOWN) { 277 277 /* Don't do anything fancy when we're shutting down anyway. */ 278 } else if (ic->flags & IRC_CHANNEL_TEMP && !(ic->flags & IRC_CHANNEL_KEEP_PLACEHOLDER)) {278 } else if (ic->flags & IRC_CHANNEL_TEMP) { 279 279 irc_channel_free_soon(ic); 280 280 } else { -
irc_im.c
r356e2dd r71074ac 576 576 ic->data = c; 577 577 578 if (ic->topic == NULL) { 579 /* New channel with no preset topic - make up a generic one */ 580 topic = g_strdup_printf( 581 "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", 582 c->title); 583 irc_channel_set_topic(ic, topic, irc->root); 584 } else { 585 /* Preset topic from the channel we picked */ 586 topic = g_strdup(ic->topic); 587 } 588 589 g_free(c->topic); 590 c->topic = topic; /* Let groupchat borrow this pointer */ 578 topic = g_strdup_printf( 579 "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", 580 c->title); 581 irc_channel_set_topic(ic, topic, irc->root); 582 g_free(topic); 591 583 592 584 return TRUE; … … 608 600 c->ui_data = NULL; 609 601 irc_channel_del_user(ic, ic->irc->user, IRC_CDU_KICK, "Chatroom closed by server"); 610 611 return TRUE;612 }613 614 static gboolean bee_irc_chat_placeholder_new(bee_t *bee, struct im_connection *ic, const char *handle,615 const char *name, const char *topic)616 {617 irc_t *irc = bee->ui_data;618 irc_channel_t *ircc;619 char *full_name = irc_channel_name_gen(irc, name);620 621 ircc = irc_channel_new(irc, full_name);622 623 set_setstr(&ircc->set, "type", "chat");624 set_setstr(&ircc->set, "chat_type", "placeholder");625 set_setstr(&ircc->set, "account", ic->acc->tag);626 set_setstr(&ircc->set, "room", (char *) handle);627 628 irc_channel_set_topic(ircc, topic, NULL);629 630 g_free(full_name);631 602 632 603 return TRUE; … … 853 824 static gboolean bee_irc_channel_chat_join(irc_channel_t *ic) 854 825 { 855 char *acc_s, *room , *chat_type;826 char *acc_s, *room; 856 827 account_t *acc; 857 828 858 chat_type = set_getstr(&ic->set, "chat_type"); 859 860 if (strcmp(chat_type, "room") != 0 && strcmp(chat_type, "placeholder") != 0) { 829 if (strcmp(set_getstr(&ic->set, "chat_type"), "room") != 0) { 861 830 return TRUE; 862 831 } … … 1014 983 struct irc_channel *ic = set->data; 1015 984 1016 ic->flags &= ~(IRC_CHANNEL_TEMP | IRC_CHANNEL_KEEP_PLACEHOLDER);1017 1018 985 if (strcmp(value, "groupchat") == 0) { 1019 986 ic->flags |= IRC_CHANNEL_TEMP; 1020 987 } else if (strcmp(value, "room") == 0) { 1021 // beep boop 1022 } else if (strcmp(value, "placeholder") == 0) { 1023 ic->flags |= IRC_CHANNEL_TEMP | IRC_CHANNEL_KEEP_PLACEHOLDER; 988 ic->flags &= ~IRC_CHANNEL_TEMP; 1024 989 } else { 1025 990 return NULL; … … 1105 1070 bee_irc_chat_new, 1106 1071 bee_irc_chat_free, 1107 bee_irc_chat_placeholder_new,1108 1072 bee_irc_chat_log, 1109 1073 bee_irc_chat_msg, -
protocols/bee.h
r356e2dd r71074ac 115 115 gboolean (*chat_new)(bee_t *bee, struct groupchat *c); 116 116 gboolean (*chat_free)(bee_t *bee, struct groupchat *c); 117 gboolean (*chat_placeholder_new)(bee_t *bee, struct im_connection *ic, const char *handle,118 const char *name, const char *topic);119 117 /* System messages of any kind. */ 120 118 gboolean (*chat_log)(bee_t *bee, struct groupchat *c, const char *text); … … 167 165 * user, too. */ 168 166 G_MODULE_EXPORT struct groupchat *imcb_chat_new(struct im_connection *ic, const char *handle); 169 G_MODULE_EXPORT void imcb_chat_placeholder_new(struct im_connection *ic, const char *handle, const char *name,170 const char *topic);171 167 G_MODULE_EXPORT void imcb_chat_name_hint(struct groupchat *c, const char *name); 172 168 G_MODULE_EXPORT void imcb_chat_free(struct groupchat *c); -
protocols/bee_chat.c
r356e2dd r71074ac 54 54 } 55 55 56 void imcb_chat_placeholder_new(struct im_connection *ic, const char *handle, const char *name, const char *topic)57 {58 bee_t *bee = ic->bee;59 60 if (bee->ui->chat_placeholder_new) {61 bee->ui->chat_placeholder_new(bee, ic, handle, name, topic);62 }63 }64 65 56 void imcb_chat_name_hint(struct groupchat *c, const char *name) 66 57 { -
protocols/jabber/Makefile
r356e2dd r71074ac 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 hipchat.o15 objects = conference.o io.o iq.o jabber.o jabber_util.o message.o presence.o s5bytestream.o sasl.o si.o 16 16 17 17 LFLAGS += -r -
protocols/jabber/conference.c
r356e2dd r71074ac 354 354 struct xt_node *subject = xt_find_node(node->children, "subject"); 355 355 struct xt_node *body = xt_find_node(node->children, "body"); 356 struct groupchat *chat = NULL; 357 struct jabber_chat *jc = NULL; 358 char *from = NULL; 359 char *nick = NULL; 360 char *final_from = NULL; 361 char *bare_jid = NULL; 362 363 from = (bud) ? bud->full_jid : xt_find_attr(node, "from"); 364 365 if (from) { 366 nick = strchr(from, '/'); 356 struct groupchat *chat = bud ? jabber_chat_by_jid(ic, bud->bare_jid) : NULL; 357 struct jabber_chat *jc = chat ? chat->data : NULL; 358 char *s; 359 360 if (subject && chat) { 361 s = (bud && bud->ext_jid) ? strchr(bud->ext_jid, '/') : NULL; 362 if (s) { 363 *s = 0; 364 } 365 imcb_chat_topic(chat, bud ? bud->ext_jid : NULL, subject->text_len > 0 ? 366 subject->text : NULL, jabber_get_timestamp(node)); 367 if (s) { 368 *s = '/'; 369 } 370 } 371 372 if (bud == NULL || (jc && ~jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me)) { 373 char *nick; 374 375 if (body == NULL || body->text_len == 0) { 376 /* Meh. Empty messages aren't very interesting, no matter 377 how much some servers love to send them. */ 378 return; 379 } 380 381 s = xt_find_attr(node, "from"); /* pkt_message() already NULL-checked this one. */ 382 nick = strchr(s, '/'); 367 383 if (nick) { 384 /* If this message included a resource/nick we don't know, 385 we might still know the groupchat itself. */ 368 386 *nick = 0; 369 } 370 chat = jabber_chat_by_jid(ic, from); 371 if (nick) { 387 chat = jabber_chat_by_jid(ic, s); 372 388 *nick = '/'; 389 373 390 nick++; 374 } 375 } 376 377 jc = (chat) ? chat->data : NULL; 378 379 if (!bud) { 380 struct xt_node *c; 381 char *s; 382 383 /* Try some clever stuff to find out the real JID here */ 384 c = xt_find_node_by_attr(node->children, "delay", "xmlns", XMLNS_DELAY); 385 386 if (c && ((s = xt_find_attr(c, "from")) || 387 (s = xt_find_attr(c, "from_jid")))) { 388 /* This won't be useful if it's the MUC JID */ 389 if (!(jc && jabber_compare_jid(s, jc->name))) { 390 /* Hopefully this one makes more sense! */ 391 bud = jabber_buddy_by_jid(ic, s, GET_BUDDY_FIRST | GET_BUDDY_CREAT); 392 } 393 } 394 395 } 396 397 if (subject && chat) { 398 char *subject_text = subject->text_len > 0 ? subject->text : NULL; 399 if (g_strcmp0(chat->topic, subject_text) != 0) { 400 bare_jid = (bud) ? jabber_get_bare_jid(bud->ext_jid) : NULL; 401 imcb_chat_topic(chat, bare_jid, subject_text, 402 jabber_get_timestamp(node)); 403 g_free(bare_jid); 404 } 405 } 406 407 if (body == NULL || body->text_len == 0) { 408 /* Meh. Empty messages aren't very interesting, no matter 409 how much some servers love to send them. */ 391 } else { 392 /* message.c uses the EXACT_JID option, so bud should 393 always be NULL here for bare JIDs. */ 394 chat = jabber_chat_by_jid(ic, s); 395 } 396 397 if (nick == NULL) { 398 /* This is fine, the groupchat itself isn't in jd->buddies. */ 399 if (chat) { 400 imcb_chat_log(chat, "From conference server: %s", body->text); 401 } else { 402 imcb_log(ic, "System message from unknown groupchat %s: %s", s, body->text); 403 } 404 } else { 405 /* This can happen too, at least when receiving a backlog when 406 just joining a channel. */ 407 if (chat) { 408 imcb_chat_log(chat, "Message from unknown participant %s: %s", nick, body->text); 409 } else { 410 imcb_log(ic, "Groupchat message from unknown JID %s: %s", s, body->text); 411 } 412 } 413 410 414 return; 411 } 412 413 if (chat == NULL) { 414 if (nick == NULL) { 415 imcb_log(ic, "System message from unknown groupchat %s: %s", from, body->text); 416 } else { 417 imcb_log(ic, "Groupchat message from unknown JID %s: %s", from, body->text); 418 } 419 415 } else if (chat == NULL) { 416 /* How could this happen?? We could do kill( self, 11 ) 417 now or just wait for the OS to do it. :-) */ 420 418 return; 421 } else if (chat != NULL && bud == NULL && nick == NULL) { 422 imcb_chat_log(chat, "From conference server: %s", body->text); 423 return; 424 } else if (jc && jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me) { 425 /* exclude self-messages since they would get filtered out 426 * but not the ones in the backlog */ 427 return; 428 } 429 430 if (bud && jc && bud != jc->me) { 431 bare_jid = jabber_get_bare_jid(bud->ext_jid ? bud->ext_jid : bud->full_jid); 432 final_from = bare_jid; 433 } else { 434 final_from = nick; 435 } 436 437 imcb_chat_msg(chat, final_from, body->text, 0, jabber_get_timestamp(node)); 438 439 g_free(bare_jid); 440 } 419 } 420 if (body && body->text_len > 0) { 421 s = (bud->ext_jid) ? strchr(bud->ext_jid, '/') : NULL; 422 if (s) { 423 *s = 0; 424 } 425 imcb_chat_msg(chat, bud->ext_jid, body->text, 0, jabber_get_timestamp(node)); 426 if (s) { 427 *s = '/'; 428 } 429 } 430 } -
protocols/jabber/iq.c
r356e2dd r71074ac 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); 29 30 30 31 xt_status jabber_pkt_iq(struct xt_node *node, gpointer data) … … 387 388 char *name = xt_find_attr(c, "name"); 388 389 char *sub = xt_find_attr(c, "subscription"); 389 char *mention_name = xt_find_attr(c, "mention_name");390 char *nick = mention_name ? : name;391 390 392 391 if (jid && sub) { … … 397 396 if (name) { 398 397 imcb_rename_buddy(ic, jid, name); 399 }400 401 if (nick) {402 imcb_buddy_nick_hint(ic, jid, nick);403 398 } 404 399 } else if (strcmp(sub, "remove") == 0) { … … 860 855 struct xt_node *node, struct xt_node *orig); 861 856 862 int jabber_iq_disco_server(struct im_connection *ic)857 static int jabber_iq_disco_server(struct im_connection *ic) 863 858 { 864 859 struct xt_node *node, *iq; -
protocols/jabber/jabber.h
r356e2dd r71074ac 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 #define XMLNS_HIPCHAT_MUC "http://hipchat.com/protocol/muc#room"242 243 238 /* jabber.c */ 244 239 void jabber_connect(struct im_connection *ic); … … 250 245 int jabber_get_roster(struct im_connection *ic); 251 246 int jabber_get_vcard(struct im_connection *ic, char *bare_jid); 252 int jabber_iq_disco_muc(struct im_connection *ic, char *muc_server);253 247 int jabber_add_to_roster(struct im_connection *ic, const char *handle, const char *name, const char *group); 254 248 int jabber_remove_from_roster(struct im_connection *ic, char *handle); … … 256 250 xt_status jabber_iq_query_server(struct im_connection *ic, char *jid, char *xmlns); 257 251 void jabber_iq_version_send(struct im_connection *ic, struct jabber_buddy *bud, void *data); 258 int jabber_iq_disco_server(struct im_connection *ic);259 252 260 253 /* si.c */ … … 314 307 void jabber_error_free(struct jabber_error *err); 315 308 gboolean jabber_set_me(struct im_connection *ic, const char *me); 316 char *jabber_get_bare_jid(char *jid);317 309 318 310 extern const struct jabber_away_state jabber_away_state_list[]; … … 350 342 void jabber_chat_invite(struct groupchat *c, char *who, char *message); 351 343 352 /* hipchat.c */353 int jabber_get_hipchat_profile(struct im_connection *ic);354 xt_status jabber_parse_hipchat_profile(struct im_connection *ic, struct xt_node *node, struct xt_node *orig);355 xt_status hipchat_handle_success(struct im_connection *ic, struct xt_node *node);356 xt_status jabber_parse_muc_list(struct im_connection *ic, struct xt_node *node, struct xt_node *orig);357 358 344 #endif -
protocols/jabber/jabber_util.c
r356e2dd r71074ac 820 820 return TRUE; 821 821 } 822 823 /* Returns new reference! g_free() afterwards. */824 char *jabber_get_bare_jid(char *jid)825 {826 char *s = NULL;827 828 if (jid == NULL) {829 return NULL;830 }831 832 if ((s = strchr(jid, '/'))) {833 return g_strndup(jid, s - jid);834 } else {835 return g_strdup(jid);836 }837 } -
protocols/jabber/sasl.c
r356e2dd r71074ac 55 55 char *s; 56 56 int sup_plain = 0, sup_digest = 0, sup_gtalk = 0, sup_fb = 0; 57 int want_oauth = FALSE , want_hipchat = FALSE;57 int want_oauth = 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);78 77 79 78 mechs = g_string_new(""); … … 112 111 113 112 reply = xt_new_node("auth", NULL, NULL); 114 if (!want_hipchat) { 115 xt_add_attr(reply, "xmlns", XMLNS_SASL); 116 } else { 117 xt_add_attr(reply, "xmlns", XMLNS_HIPCHAT); 118 } 113 xt_add_attr(reply, "xmlns", XMLNS_SASL); 119 114 120 115 if (sup_gtalk && want_oauth) { … … 148 143 } else if (sup_plain) { 149 144 int len; 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); 145 146 xt_add_attr(reply, "mechanism", "PLAIN"); 162 147 163 148 /* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */ 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 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); 177 154 reply->text = base64_encode((unsigned char *) s, len); 178 155 reply->text_len = strlen(reply->text); … … 420 397 imcb_log(ic, "Authentication finished"); 421 398 jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART; 422 423 if (jd->flags & JFLAG_HIPCHAT) {424 return hipchat_handle_success(ic, node);425 }426 399 } else if (strcmp(node->name, "failure") == 0) { 427 400 imcb_error(ic, "Authentication failure");
Note: See TracChangeset
for help on using the changeset viewer.