Changeset a42fda4 for irc_im.c


Ignore:
Timestamp:
2016-03-20T03:58:05Z (5 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
8f8a56f
Parents:
14f912d
git-author:
dequis <dx@…> (08-12-15 22:31:05)
git-committer:
dequis <dx@…> (20-03-16 03:58:05)
Message:

Add imcb_buddy_nick_change(), like nick_hint but stronger

nick_hint only works when creating new users, it's a no-op after the
user is online. This new function takes care of nick changes after that.

It also helps clean up couple of hacks in irc_im.c \o/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_im.c

    r14f912d ra42fda4  
    342342}
    343343
    344 static gboolean bee_irc_user_nick_update(irc_user_t *iu);
     344static gboolean bee_irc_user_nick_update(irc_user_t *iu, gboolean offline_only);
    345345
    346346static gboolean bee_irc_user_fullname(bee_t *bee, bee_user_t *bu)
     
    370370        }
    371371
    372         bee_irc_user_nick_update(iu);
     372        bee_irc_user_nick_update(iu, TRUE);
    373373
    374374        return TRUE;
     
    377377static gboolean bee_irc_user_nick_hint(bee_t *bee, bee_user_t *bu, const char *hint)
    378378{
    379         bee_irc_user_nick_update((irc_user_t *) bu->ui_data);
     379        bee_irc_user_nick_update((irc_user_t *) bu->ui_data, TRUE);
     380
     381        return TRUE;
     382}
     383
     384static gboolean bee_irc_user_nick_change(bee_t *bee, bee_user_t *bu, const char *nick)
     385{
     386        bee_irc_user_nick_update((irc_user_t *) bu->ui_data, FALSE);
    380387
    381388        return TRUE;
     
    386393        irc_user_t *iu = (irc_user_t *) bu->ui_data;
    387394        irc_t *irc = (irc_t *) bee->ui_data;
    388         bee_user_flags_t online;
    389 
    390         /* Take the user offline temporarily so we can change the nick (if necessary). */
    391         if ((online = bu->flags & BEE_USER_ONLINE)) {
    392                 bu->flags &= ~BEE_USER_ONLINE;
    393         }
    394395
    395396        bee_irc_channel_update(irc, NULL, iu);
    396         bee_irc_user_nick_update(iu);
    397 
    398         if (online) {
    399                 bu->flags |= online;
    400                 bee_irc_channel_update(irc, NULL, iu);
    401         }
    402 
    403         return TRUE;
    404 }
    405 
    406 static gboolean bee_irc_user_nick_update(irc_user_t *iu)
     397        bee_irc_user_nick_update(iu, FALSE);
     398
     399        return TRUE;
     400}
     401
     402static gboolean bee_irc_user_nick_update(irc_user_t *iu, gboolean offline_only)
    407403{
    408404        bee_user_t *bu = iu->bu;
    409405        char *newnick;
    410406
    411         if (bu->flags & BEE_USER_ONLINE) {
     407        if (offline_only && bu->flags & BEE_USER_ONLINE) {
    412408                /* Ignore if the user is visible already. */
    413409                return TRUE;
     
    432428{
    433429        bee_user_t *bu = iu->bu;
    434         bee_user_flags_t online;
    435430
    436431        if (bu == FALSE) {
     
    438433        }
    439434
    440         /* In this case, pretend the user is offline. */
    441         if ((online = bu->flags & BEE_USER_ONLINE)) {
    442                 bu->flags &= ~BEE_USER_ONLINE;
    443         }
    444 
    445435        nick_del(bu);
    446         bee_irc_user_nick_update(iu);
    447 
    448         bu->flags |= online;
     436        bee_irc_user_nick_update(iu, FALSE);
     437
    449438}
    450439
     
    11461135
    11471136        bee_irc_log,
     1137        bee_irc_user_nick_change,
    11481138};
Note: See TracChangeset for help on using the changeset viewer.