Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jabglue.c @ 1290:e42f48103609
Drawing the MUC nicks by a different color
(color is hardcoded to red, needs to be changed to something useable)
author | Michal 'vorner' Vaner <vorner@ucw.cz> |
---|---|
date | Sun, 26 Aug 2007 18:24:14 +0200 |
parents | d438b56990cd |
children | 3b338a5c01fc |
comparison
equal
deleted
inserted
replaced
1289:57fe57474122 | 1290:e42f48103609 |
---|---|
1643 g_free(res_pgpdata->sign_keyid); | 1643 g_free(res_pgpdata->sign_keyid); |
1644 res_pgpdata->sign_keyid = key; | 1644 res_pgpdata->sign_keyid = key; |
1645 res_pgpdata->last_sigsum = sigsum; | 1645 res_pgpdata->last_sigsum = sigsum; |
1646 if (sigsum & GPGME_SIGSUM_RED) { | 1646 if (sigsum & GPGME_SIGSUM_RED) { |
1647 buf = g_strdup_printf("Bad signature from <%s/%s>", barejid, rname); | 1647 buf = g_strdup_printf("Bad signature from <%s/%s>", barejid, rname); |
1648 scr_WriteIncomingMessage(barejid, buf, 0, HBB_PREFIX_INFO); | 1648 scr_WriteIncomingMessage(barejid, buf, 0, HBB_PREFIX_INFO, 0); |
1649 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 1649 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
1650 g_free(buf); | 1650 g_free(buf); |
1651 } | 1651 } |
1652 // Verify that the key id is the one we expect. | 1652 // Verify that the key id is the one we expect. |
1653 expectedkey = settings_pgp_getkeyid(barejid); | 1653 expectedkey = settings_pgp_getkeyid(barejid); |
1654 if (keys_mismatch(key, expectedkey)) { | 1654 if (keys_mismatch(key, expectedkey)) { |
1655 buf = g_strdup_printf("Warning: The KeyId from <%s/%s> doesn't match " | 1655 buf = g_strdup_printf("Warning: The KeyId from <%s/%s> doesn't match " |
1656 "the key you set up", barejid, rname); | 1656 "the key you set up", barejid, rname); |
1657 scr_WriteIncomingMessage(barejid, buf, 0, HBB_PREFIX_INFO); | 1657 scr_WriteIncomingMessage(barejid, buf, 0, HBB_PREFIX_INFO, 0); |
1658 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 1658 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
1659 g_free(buf); | 1659 g_free(buf); |
1660 } | 1660 } |
1661 } | 1661 } |
1662 #endif | 1662 #endif |
1696 GSList *room_elt; | 1696 GSList *room_elt; |
1697 char *mbuf; | 1697 char *mbuf; |
1698 | 1698 |
1699 mbuf = g_strdup_printf("Unexpected groupchat packet!"); | 1699 mbuf = g_strdup_printf("Unexpected groupchat packet!"); |
1700 scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf); | 1700 scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf); |
1701 scr_WriteIncomingMessage(bjid, mbuf, 0, HBB_PREFIX_INFO); | 1701 scr_WriteIncomingMessage(bjid, mbuf, 0, HBB_PREFIX_INFO, 0); |
1702 g_free(mbuf); | 1702 g_free(mbuf); |
1703 | 1703 |
1704 // Send back an unavailable packet | 1704 // Send back an unavailable packet |
1705 jb_setstatus(offline, bjid, "", TRUE); | 1705 jb_setstatus(offline, bjid, "", TRUE); |
1706 | 1706 |
1986 if (!ournick) { | 1986 if (!ournick) { |
1987 // It shouldn't happen, probably a server issue | 1987 // It shouldn't happen, probably a server issue |
1988 mbuf = g_strdup_printf("Unexpected groupchat packet!"); | 1988 mbuf = g_strdup_printf("Unexpected groupchat packet!"); |
1989 | 1989 |
1990 scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf); | 1990 scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf); |
1991 scr_WriteIncomingMessage(roomjid, mbuf, 0, HBB_PREFIX_INFO); | 1991 scr_WriteIncomingMessage(roomjid, mbuf, 0, HBB_PREFIX_INFO, 0); |
1992 g_free(mbuf); | 1992 g_free(mbuf); |
1993 // Send back an unavailable packet | 1993 // Send back an unavailable packet |
1994 jb_setstatus(offline, roomjid, "", TRUE); | 1994 jb_setstatus(offline, roomjid, "", TRUE); |
1995 scr_DrawRoster(); | 1995 scr_DrawRoster(); |
1996 return; | 1996 return; |
2011 | 2011 |
2012 // Check for nickname change | 2012 // Check for nickname change |
2013 if (statuscode == 303 && mbnick) { | 2013 if (statuscode == 303 && mbnick) { |
2014 mbuf = g_strdup_printf("%s is now known as %s", rname, mbnick); | 2014 mbuf = g_strdup_printf("%s is now known as %s", rname, mbnick); |
2015 scr_WriteIncomingMessage(roomjid, mbuf, usttime, | 2015 scr_WriteIncomingMessage(roomjid, mbuf, usttime, |
2016 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG); | 2016 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
2017 if (log_muc_conf) | 2017 if (log_muc_conf) |
2018 hlog_write_message(roomjid, 0, FALSE, mbuf); | 2018 hlog_write_message(roomjid, 0, FALSE, mbuf); |
2019 g_free(mbuf); | 2019 g_free(mbuf); |
2020 buddy_resource_setname(room_elt->data, rname, mbnick); | 2020 buddy_resource_setname(room_elt->data, rname, mbnick); |
2021 // Maybe it's _our_ nickname... | 2021 // Maybe it's _our_ nickname... |
2096 | 2096 |
2097 msgflags = HBB_PREFIX_INFO; | 2097 msgflags = HBB_PREFIX_INFO; |
2098 if (!we_left && settings_opt_get_int("muc_flag_joins") != 2) | 2098 if (!we_left && settings_opt_get_int("muc_flag_joins") != 2) |
2099 msgflags |= HBB_PREFIX_NOFLAG; | 2099 msgflags |= HBB_PREFIX_NOFLAG; |
2100 | 2100 |
2101 scr_WriteIncomingMessage(roomjid, mbuf, usttime, msgflags); | 2101 scr_WriteIncomingMessage(roomjid, mbuf, usttime, msgflags, 0); |
2102 | 2102 |
2103 if (log_muc_conf) | 2103 if (log_muc_conf) |
2104 hlog_write_message(roomjid, 0, FALSE, mbuf); | 2104 hlog_write_message(roomjid, 0, FALSE, mbuf); |
2105 | 2105 |
2106 if (we_left) { | 2106 if (we_left) { |
2129 if (strcmp(ournick, rname)) { | 2129 if (strcmp(ournick, rname)) { |
2130 // Display current mbuf and create a new message for the member | 2130 // Display current mbuf and create a new message for the member |
2131 // Note: the usttime timestamp is related to the other member, | 2131 // Note: the usttime timestamp is related to the other member, |
2132 // so we use 0 here. | 2132 // so we use 0 here. |
2133 scr_WriteIncomingMessage(roomjid, mbuf, 0, | 2133 scr_WriteIncomingMessage(roomjid, mbuf, 0, |
2134 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG); | 2134 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
2135 if (log_muc_conf) | 2135 if (log_muc_conf) |
2136 hlog_write_message(roomjid, 0, FALSE, mbuf); | 2136 hlog_write_message(roomjid, 0, FALSE, mbuf); |
2137 g_free(mbuf); | 2137 g_free(mbuf); |
2138 mbuf = g_strdup_printf("%s has joined", rname); | 2138 mbuf = g_strdup_printf("%s has joined", rname); |
2139 new_member = TRUE; | 2139 new_member = TRUE; |
2148 | 2148 |
2149 if (mbuf) { | 2149 if (mbuf) { |
2150 msgflags = HBB_PREFIX_INFO; | 2150 msgflags = HBB_PREFIX_INFO; |
2151 if (!settings_opt_get_int("muc_flag_joins")) | 2151 if (!settings_opt_get_int("muc_flag_joins")) |
2152 msgflags |= HBB_PREFIX_NOFLAG; | 2152 msgflags |= HBB_PREFIX_NOFLAG; |
2153 scr_WriteIncomingMessage(roomjid, mbuf, usttime, msgflags); | 2153 scr_WriteIncomingMessage(roomjid, mbuf, usttime, msgflags, 0); |
2154 if (log_muc_conf) | 2154 if (log_muc_conf) |
2155 hlog_write_message(roomjid, 0, FALSE, mbuf); | 2155 hlog_write_message(roomjid, 0, FALSE, mbuf); |
2156 g_free(mbuf); | 2156 g_free(mbuf); |
2157 } | 2157 } |
2158 } | 2158 } |
2274 g_string_printf(sbuf, "Received an invitation to <%s>, from <%s>", | 2274 g_string_printf(sbuf, "Received an invitation to <%s>, from <%s>", |
2275 to, from); | 2275 to, from); |
2276 } | 2276 } |
2277 | 2277 |
2278 barejid = jidtodisp(from); | 2278 barejid = jidtodisp(from); |
2279 scr_WriteIncomingMessage(barejid, sbuf->str, 0, HBB_PREFIX_INFO); | 2279 scr_WriteIncomingMessage(barejid, sbuf->str, 0, HBB_PREFIX_INFO, 0); |
2280 scr_LogPrint(LPRINT_LOGNORM, "%s", sbuf->str); | 2280 scr_LogPrint(LPRINT_LOGNORM, "%s", sbuf->str); |
2281 | 2281 |
2282 evn = evs_new(EVS_TYPE_INVITATION, EVS_MAX_TIMEOUT); | 2282 evn = evs_new(EVS_TYPE_INVITATION, EVS_MAX_TIMEOUT); |
2283 if (evn) { | 2283 if (evn) { |
2284 evn->callback = &evscallback_invitation; | 2284 evn->callback = &evscallback_invitation; |
2291 evn->desc = g_strdup_printf("<%s> invites you to %s ", from, to); | 2291 evn->desc = g_strdup_printf("<%s> invites you to %s ", from, to); |
2292 g_string_printf(sbuf, "Please use /event %s accept|reject", evn->id); | 2292 g_string_printf(sbuf, "Please use /event %s accept|reject", evn->id); |
2293 } else { | 2293 } else { |
2294 g_string_printf(sbuf, "Unable to create a new event!"); | 2294 g_string_printf(sbuf, "Unable to create a new event!"); |
2295 } | 2295 } |
2296 scr_WriteIncomingMessage(barejid, sbuf->str, 0, HBB_PREFIX_INFO); | 2296 scr_WriteIncomingMessage(barejid, sbuf->str, 0, HBB_PREFIX_INFO, 0); |
2297 scr_LogPrint(LPRINT_LOGNORM, "%s", sbuf->str); | 2297 scr_LogPrint(LPRINT_LOGNORM, "%s", sbuf->str); |
2298 g_string_free(sbuf, TRUE); | 2298 g_string_free(sbuf, TRUE); |
2299 | 2299 |
2300 // Make sure the barejid is a room in the roster | 2300 // Make sure the barejid is a room in the roster |
2301 room_elt = roster_find(barejid, jidsearch, 0); | 2301 room_elt = roster_find(barejid, jidsearch, 0); |
2366 mbuf = g_strdup_printf("The topic has been set to: %s", subj); | 2366 mbuf = g_strdup_printf("The topic has been set to: %s", subj); |
2367 } else { | 2367 } else { |
2368 mbuf = g_strdup_printf("%s has set the topic to: %s", r, subj); | 2368 mbuf = g_strdup_printf("%s has set the topic to: %s", r, subj); |
2369 } | 2369 } |
2370 scr_WriteIncomingMessage(s, mbuf, 0, | 2370 scr_WriteIncomingMessage(s, mbuf, 0, |
2371 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG); | 2371 HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); |
2372 if (settings_opt_get_int("log_muc_conf")) | 2372 if (settings_opt_get_int("log_muc_conf")) |
2373 hlog_write_message(s, 0, FALSE, mbuf); | 2373 hlog_write_message(s, 0, FALSE, mbuf); |
2374 g_free(s); | 2374 g_free(s); |
2375 g_free(mbuf); | 2375 g_free(mbuf); |
2376 // The topic is displayed in the chat status line, so refresh now. | 2376 // The topic is displayed in the chat status line, so refresh now. |
2573 // Remove the buddy from the roster if there is no current subscription | 2573 // Remove the buddy from the roster if there is no current subscription |
2574 if (roster_getsubscription(barejid) == sub_none) | 2574 if (roster_getsubscription(barejid) == sub_none) |
2575 jb_delbuddy(barejid); | 2575 jb_delbuddy(barejid); |
2576 } | 2576 } |
2577 } | 2577 } |
2578 scr_WriteIncomingMessage(barejid, buf, 0, HBB_PREFIX_INFO); | 2578 scr_WriteIncomingMessage(barejid, buf, 0, HBB_PREFIX_INFO, 0); |
2579 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 2579 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
2580 g_free(buf); | 2580 g_free(buf); |
2581 return 0; | 2581 return 0; |
2582 } | 2582 } |
2583 | 2583 |
2670 isagent = (roster_gettype(r) & ROSTER_TYPE_AGENT) != 0; | 2670 isagent = (roster_gettype(r) & ROSTER_TYPE_AGENT) != 0; |
2671 msg = xmlnode_get_tag_data(xmldata, "status"); | 2671 msg = xmlnode_get_tag_data(xmldata, "status"); |
2672 | 2672 |
2673 buf = g_strdup_printf("<%s> wants to subscribe to your presence updates", | 2673 buf = g_strdup_printf("<%s> wants to subscribe to your presence updates", |
2674 from); | 2674 from); |
2675 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO); | 2675 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); |
2676 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 2676 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
2677 g_free(buf); | 2677 g_free(buf); |
2678 | 2678 |
2679 if (msg) { | 2679 if (msg) { |
2680 buf = g_strdup_printf("<%s> said: %s", from, msg); | 2680 buf = g_strdup_printf("<%s> said: %s", from, msg); |
2681 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO); | 2681 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); |
2682 replace_nl_with_dots(buf); | 2682 replace_nl_with_dots(buf); |
2683 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 2683 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
2684 g_free(buf); | 2684 g_free(buf); |
2685 } | 2685 } |
2686 | 2686 |
2693 "presence updates", r); | 2693 "presence updates", r); |
2694 buf = g_strdup_printf("Please use /event %s accept|reject", evn->id); | 2694 buf = g_strdup_printf("Please use /event %s accept|reject", evn->id); |
2695 } else { | 2695 } else { |
2696 buf = g_strdup_printf("Unable to create a new event!"); | 2696 buf = g_strdup_printf("Unable to create a new event!"); |
2697 } | 2697 } |
2698 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO); | 2698 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); |
2699 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 2699 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
2700 g_free(buf); | 2700 g_free(buf); |
2701 } else if (!strcmp(type, "unsubscribe")) { | 2701 } else if (!strcmp(type, "unsubscribe")) { |
2702 /* The sender is unsubscribing from our presence */ | 2702 /* The sender is unsubscribing from our presence */ |
2703 jb_subscr_cancel_auth(from); | 2703 jb_subscr_cancel_auth(from); |
2704 buf = g_strdup_printf("<%s> is unsubscribing from your " | 2704 buf = g_strdup_printf("<%s> is unsubscribing from your " |
2705 "presence updates", from); | 2705 "presence updates", from); |
2706 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO); | 2706 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); |
2707 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 2707 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
2708 g_free(buf); | 2708 g_free(buf); |
2709 } else if (!strcmp(type, "subscribed")) { | 2709 } else if (!strcmp(type, "subscribed")) { |
2710 /* The sender has allowed us to receive their presence */ | 2710 /* The sender has allowed us to receive their presence */ |
2711 buf = g_strdup_printf("<%s> has allowed you to receive their " | 2711 buf = g_strdup_printf("<%s> has allowed you to receive their " |
2712 "presence updates", from); | 2712 "presence updates", from); |
2713 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO); | 2713 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); |
2714 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 2714 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
2715 g_free(buf); | 2715 g_free(buf); |
2716 } else if (!strcmp(type, "unsubscribed")) { | 2716 } else if (!strcmp(type, "unsubscribed")) { |
2717 /* The subscription request has been denied or a previously-granted | 2717 /* The subscription request has been denied or a previously-granted |
2718 subscription has been cancelled */ | 2718 subscription has been cancelled */ |
2719 roster_unsubscribed(from); | 2719 roster_unsubscribed(from); |
2720 update_roster = TRUE; | 2720 update_roster = TRUE; |
2721 buf = g_strdup_printf("<%s> has cancelled your subscription to " | 2721 buf = g_strdup_printf("<%s> has cancelled your subscription to " |
2722 "their presence updates", from); | 2722 "their presence updates", from); |
2723 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO); | 2723 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); |
2724 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 2724 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
2725 g_free(buf); | 2725 g_free(buf); |
2726 } else { | 2726 } else { |
2727 scr_LogPrint(LPRINT_LOGNORM, "Received unrecognized packet from <%s>, " | 2727 scr_LogPrint(LPRINT_LOGNORM, "Received unrecognized packet from <%s>, " |
2728 "type=%s", from, (type ? type : "")); | 2728 "type=%s", from, (type ? type : "")); |