Changeset e3e2059 for irc_im.c


Ignore:
Timestamp:
2015-04-06T12:35:57Z (6 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
8bcd160
Parents:
69982f8
git-author:
dequis <dx@…> (06-04-15 12:30:30)
git-committer:
dequis <dx@…> (06-04-15 12:35:57)
Message:

irc: split bee_irc_chat_name_hint in a few functions

Also split underscore_dedupe from nick_dedupe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_im.c

    r69982f8 re3e2059  
    696696static gboolean bee_irc_chat_name_hint(bee_t *bee, struct groupchat *c, const char *name)
    697697{
    698         irc_t *irc = bee->ui_data;
    699         irc_channel_t *ic = c->ui_data, *oic;
    700         char *stripped, *full_name;
    701         gsize bytes_written;
    702 
    703         if (ic == NULL) {
    704                 return FALSE;
    705         }
    706 
    707         /* Don't rename a channel if the user's in it already. */
    708         if (ic->flags & IRC_CHANNEL_JOINED) {
    709                 return FALSE;
    710         }
    711 
    712         stripped = g_convert_with_fallback(name, -1, "ASCII//TRANSLIT", "UTF-8", "", NULL, &bytes_written, NULL);
    713         if (bytes_written > MAX_NICK_LENGTH) {
    714                 stripped[MAX_NICK_LENGTH] = '\0';
    715         }
    716 
    717         irc_channel_name_strip(stripped);
    718         if (set_getbool(&bee->set, "lcnicks")) {
    719                 nick_lc(irc, stripped);
    720         }
    721 
    722         if (stripped[0] == '\0') {
    723                 g_free(stripped);
    724                 return FALSE;
    725         }
    726 
    727         full_name = g_strdup_printf("#%s", stripped);
    728         g_free(stripped);
    729         if ((oic = irc_channel_by_name(irc, full_name))) {
    730                 char *type, *chat_type;
    731 
    732                 type = set_getstr(&oic->set, "type");
    733                 chat_type = set_getstr(&oic->set, "chat_type");
    734 
    735                 if (type && chat_type && oic->data == FALSE &&
    736                     strcmp(type, "chat") == 0 &&
    737                     strcmp(chat_type, "groupchat") == 0) {
    738                         /* There's a channel with this name already, but it looks
    739                            like it's not in use yet. Most likely the IRC client
    740                            rejoined the channel after a reconnect. Remove it so
    741                            we can reuse its name. */
    742                         irc_channel_free(oic);
    743                 } else {
    744                         g_free(full_name);
    745                         return FALSE;
    746                 }
    747         }
    748 
    749         g_free(ic->name);
    750         ic->name = full_name;
    751 
    752         return TRUE;
     698        return irc_channel_name_hint(c->ui_data, name);
    753699}
    754700
Note: See TracChangeset for help on using the changeset viewer.