Changes in / [8fdeaa5:29ff5c2]


Ignore:
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • irc.h

    r8fdeaa5 r29ff5c2  
    157157        IRC_CHANNEL_TEMP = 2,   /* Erase the channel when the user leaves,
    158158                                   and don't save it. */
     159
     160        /* Show a placeholder of the channel in listings, but don't save it */
     161        IRC_CHANNEL_KEEP_PLACEHOLDER = 4,
    159162
    160163        /* Hack: Set this flag right before jumping into IM when we expect
  • irc_channel.c

    r8fdeaa5 r29ff5c2  
    276276                if (ic->irc->status & USTATUS_SHUTDOWN) {
    277277                        /* Don't do anything fancy when we're shutting down anyway. */
    278                 } else if (ic->flags & IRC_CHANNEL_TEMP) {
     278                } else if (ic->flags & IRC_CHANNEL_TEMP && !(ic->flags & IRC_CHANNEL_KEEP_PLACEHOLDER)) {
    279279                        irc_channel_free_soon(ic);
    280280                } else {
  • irc_im.c

    r8fdeaa5 r29ff5c2  
    620620        ic->data = c;
    621621
    622         topic = g_strdup_printf(
    623                 "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!",
    624                 c->title);
    625         irc_channel_set_topic(ic, topic, irc->root);
    626         g_free(topic);
     622        if (ic->topic == NULL) {
     623                /* New channel with no preset topic - make up a generic one */
     624                topic = g_strdup_printf(
     625                        "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!",
     626                        c->title);
     627                irc_channel_set_topic(ic, topic, irc->root);
     628        } else {
     629                /* Preset topic from the channel we picked */
     630                topic = g_strdup(ic->topic);
     631        }
     632
     633        g_free(c->topic);
     634        c->topic = topic;         /* Let groupchat borrow this pointer */
    627635
    628636        return TRUE;
     
    644652        c->ui_data = NULL;
    645653        irc_channel_del_user(ic, ic->irc->user, IRC_CDU_KICK, "Chatroom closed by server");
     654
     655        return TRUE;
     656}
     657
     658static gboolean bee_irc_chat_placeholder_new(bee_t *bee, struct im_connection *ic, const char *handle,
     659                                             const char *name, const char *topic)
     660{
     661        irc_t *irc = bee->ui_data;
     662        irc_channel_t *ircc;
     663        char *full_name = irc_channel_name_gen(irc, name);
     664
     665        ircc = irc_channel_new(irc, full_name);
     666
     667        set_setstr(&ircc->set, "type", "chat");
     668        set_setstr(&ircc->set, "chat_type", "placeholder");
     669        set_setstr(&ircc->set, "account", ic->acc->tag);
     670        set_setstr(&ircc->set, "room", (char *) handle);
     671
     672        irc_channel_set_topic(ircc, topic, NULL);
     673
     674        g_free(full_name);
    646675
    647676        return TRUE;
     
    870899static gboolean bee_irc_channel_chat_join(irc_channel_t *ic)
    871900{
    872         char *acc_s, *room;
     901        char *acc_s, *room, *chat_type;
    873902        account_t *acc;
    874903
    875         if (strcmp(set_getstr(&ic->set, "chat_type"), "room") != 0) {
     904        chat_type = set_getstr(&ic->set, "chat_type");
     905
     906        if (strcmp(chat_type, "room") != 0 && strcmp(chat_type, "placeholder") != 0) {
    876907                return TRUE;
    877908        }
     
    10331064        struct irc_channel *ic = set->data;
    10341065
     1066        ic->flags &= ~(IRC_CHANNEL_TEMP | IRC_CHANNEL_KEEP_PLACEHOLDER);
     1067
    10351068        if (strcmp(value, "groupchat") == 0) {
    10361069                ic->flags |= IRC_CHANNEL_TEMP;
    10371070        } else if (strcmp(value, "room") == 0) {
    1038                 ic->flags &= ~IRC_CHANNEL_TEMP;
     1071                // beep boop
     1072        } else if (strcmp(value, "placeholder") == 0) {
     1073                ic->flags |= IRC_CHANNEL_TEMP | IRC_CHANNEL_KEEP_PLACEHOLDER;
    10391074        } else {
    10401075                return NULL;
     
    11201155        bee_irc_chat_new,
    11211156        bee_irc_chat_free,
     1157        bee_irc_chat_placeholder_new,
    11221158        bee_irc_chat_log,
    11231159        bee_irc_chat_msg,
  • protocols/bee.h

    r8fdeaa5 r29ff5c2  
    116116        gboolean (*chat_new)(bee_t *bee, struct groupchat *c);
    117117        gboolean (*chat_free)(bee_t *bee, struct groupchat *c);
     118        gboolean (*chat_placeholder_new)(bee_t *bee, struct im_connection *ic, const char *handle,
     119                                         const char *name, const char *topic);
    118120        /* System messages of any kind. */
    119121        gboolean (*chat_log)(bee_t *bee, struct groupchat *c, const char *text);
     
    167169 *   user, too. */
    168170G_MODULE_EXPORT struct groupchat *imcb_chat_new(struct im_connection *ic, const char *handle);
     171G_MODULE_EXPORT void imcb_chat_placeholder_new(struct im_connection *ic, const char *handle, const char *name,
     172                                               const char *topic);
    169173G_MODULE_EXPORT void imcb_chat_name_hint(struct groupchat *c, const char *name);
    170174G_MODULE_EXPORT void imcb_chat_free(struct groupchat *c);
  • protocols/bee_chat.c

    r8fdeaa5 r29ff5c2  
    5454}
    5555
     56void 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
    5665void imcb_chat_name_hint(struct groupchat *c, const char *name)
    5766{
  • protocols/jabber/hipchat.c

    r8fdeaa5 r29ff5c2  
    2727{
    2828        struct jabber_data *jd = ic->proto_data;
    29         char *sep, *jid;
     29        char *sep, *jid, *muc_host;
    3030
    3131        jid = xt_find_attr(node, "jid");
     32        muc_host = xt_find_attr(node, "muc_host");
    3233
    3334        sep = strchr(jid, '/');
     
    4849        if (!jabber_get_roster(ic) ||
    4950            !jabber_iq_disco_server(ic) ||
    50             !jabber_get_hipchat_profile(ic)) {
     51            !jabber_get_hipchat_profile(ic) ||
     52            !jabber_iq_disco_muc(ic, muc_host)) {
    5153                return XT_ABORT;
    5254        }
     
    9294
    9395}
     96
     97int jabber_iq_disco_muc(struct im_connection *ic, char *muc_server)
     98{
     99        struct xt_node *node;
     100        int st;
     101
     102        imcb_log(ic, "Fetching MUC list");
     103
     104        node = xt_new_node("query", NULL, NULL);
     105        xt_add_attr(node, "xmlns", XMLNS_DISCO_ITEMS);
     106        node = jabber_make_packet("iq", "get", muc_server, node);
     107
     108        jabber_cache_add(ic, node, jabber_parse_muc_list);
     109        st = jabber_write_packet(ic, node);
     110
     111        return st;
     112}
     113
     114xt_status jabber_parse_muc_list(struct im_connection *ic, struct xt_node *node, struct xt_node *orig)
     115{
     116        struct xt_node *query, *c;
     117
     118        if (!(query = xt_find_node(node->children, "query"))) {
     119                imcb_log(ic, "Warning: Received NULL MUC list packet");
     120                return XT_HANDLED;
     121        }
     122
     123        c = query->children;
     124        while ((c = xt_find_node(c, "item"))) {
     125                struct xt_node *c2;
     126                char *topic = NULL;
     127                char *jid = xt_find_attr(c, "jid");
     128                char *name = xt_find_attr(c, "name");
     129
     130                imcb_log(ic, "Debug: adding MUC to channel list: %s - '%s'", jid, name);
     131
     132                if ((c2 = xt_find_node_by_attr(c->children, "x", "xmlns", XMLNS_HIPCHAT_MUC)) &&
     133                    (c2 = xt_find_node(c2->children, "topic"))) {
     134                        topic = c2->text;
     135                }
     136
     137                imcb_chat_placeholder_new(ic, jid, name, topic);
     138                c = c->next;
     139        }
     140        return XT_HANDLED;
     141
     142}
  • protocols/jabber/jabber.h

    r8fdeaa5 r29ff5c2  
    243243#define XMLNS_HIPCHAT         "http://hipchat.com"
    244244#define XMLNS_HIPCHAT_PROFILE "http://hipchat.com/protocol/profile"
     245#define XMLNS_HIPCHAT_MUC     "http://hipchat.com/protocol/muc#room"
    245246
    246247/* jabber.c */
     
    253254int jabber_get_roster(struct im_connection *ic);
    254255int jabber_get_vcard(struct im_connection *ic, char *bare_jid);
     256int jabber_iq_disco_muc(struct im_connection *ic, char *muc_server);
    255257int jabber_add_to_roster(struct im_connection *ic, const char *handle, const char *name, const char *group);
    256258int jabber_remove_from_roster(struct im_connection *ic, char *handle);
     
    356358xt_status jabber_parse_hipchat_profile(struct im_connection *ic, struct xt_node *node, struct xt_node *orig);
    357359xt_status hipchat_handle_success(struct im_connection *ic, struct xt_node *node);
     360xt_status jabber_parse_muc_list(struct im_connection *ic, struct xt_node *node, struct xt_node *orig);
    358361
    359362#endif
Note: See TracChangeset for help on using the changeset viewer.