Changeset 687ec88


Ignore:
Timestamp:
2015-10-08T05:25:56Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
2f73692
Parents:
0b0bb4c
git-author:
dequis <dx@…> (12-09-15 08:25:33)
git-committer:
dequis <dx@…> (08-10-15 05:25:56)
Message:

IRCv3 multi-prefix... but mostly just adding prefixes to WHO

We can't actually have multiple prefixes internally, so the only thing
missing for multi-prefix compliance is actually having the prefix in the
WHO reply, which is a rfc1459 thing.

Note to future self: check irc logs for the implementation I threw away.
The one that actually handled multiple prefixes. I hope that's useful.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • irc.h

    r0b0bb4c r687ec88  
    6767
    6868typedef enum {
    69         CAP_FOO = (1 << 0),
    70         CAP_BAR = (1 << 1),
     69        CAP_MULTI_PREFIX = (1 << 1),
    7170} irc_cap_flag_t;
    7271
     
    309308gboolean irc_channel_name_hint(irc_channel_t *ic, const char *name);
    310309void irc_channel_update_ops(irc_channel_t *ic, char *value);
     310char irc_channel_user_get_prefix(irc_channel_user_t *icu);
    311311char *set_eval_irc_channel_ops(struct set *set, char *value);
    312312gboolean irc_channel_wants_user(irc_channel_t *ic, irc_user_t *iu);
  • irc_cap.c

    r0b0bb4c r687ec88  
    3838
    3939static const cap_info_t supported_caps[] = {
    40         {"foo", CAP_FOO},
    41         {"bar", CAP_BAR},
     40        {"multi-prefix", CAP_MULTI_PREFIX},
    4241        {NULL},
    4342};
  • irc_channel.c

    r0b0bb4c r687ec88  
    427427                          changes);
    428428        }
     429}
     430
     431char irc_channel_user_get_prefix(irc_channel_user_t *icu)
     432{
     433        if (icu->flags & IRC_CHANNEL_USER_OP) {
     434                return '@';
     435        } else if (icu->flags & IRC_CHANNEL_USER_HALFOP) {
     436                return '%';
     437        } else if (icu->flags & IRC_CHANNEL_USER_VOICE) {
     438                return '+';
     439        }
     440        return 0;
    429441}
    430442
  • irc_send.c

    r0b0bb4c r687ec88  
    214214                }
    215215
    216                 if (icu->flags & IRC_CHANNEL_USER_OP) {
    217                         strcat(namelist, "@");
    218                 } else if (icu->flags & IRC_CHANNEL_USER_HALFOP) {
    219                         strcat(namelist, "%");
    220                 } else if (icu->flags & IRC_CHANNEL_USER_VOICE) {
    221                         strcat(namelist, "+");
    222                 }
     216                namelist[strlen(namelist) + 1] = '\0';
     217                namelist[strlen(namelist)] = irc_channel_user_get_prefix(icu);
    223218
    224219                strcat(namelist, iu->nick);
     
    294289
    295290        while (l) {
    296                 irc_user_t *iu = l->data;
     291                irc_user_t *iu;
     292
     293                /* Null terminated string with three chars, respectively:
     294                 * { <H|G>, <@|%|+|\0>, \0 } */
     295                char status_prefix[3] = {0};
     296
     297                /* rfc1459 doesn't mention this: G means gone, H means here */
     298                status_prefix[0] = iu->flags & IRC_USER_AWAY ? 'G' : 'H';
     299
    297300                if (is_channel) {
    298                         iu = ((irc_channel_user_t *) iu)->iu;
    299                 }
    300                 /* TODO(wilmer): Restore away/channel information here */
    301                 irc_send_num(irc, 352, "%s %s %s %s %s %c :0 %s",
     301                        irc_channel_user_t *icu = l->data;
     302                        status_prefix[1] = irc_channel_user_get_prefix(icu);
     303                        iu = icu->iu;
     304                } else {
     305                        iu = l->data;
     306                }
     307
     308                irc_send_num(irc, 352, "%s %s %s %s %s %s :0 %s",
    302309                             is_channel ? channel : "*", iu->user, iu->host, irc->root->host,
    303                              iu->nick, iu->flags & IRC_USER_AWAY ? 'G' : 'H',
    304                              iu->fullname);
     310                             iu->nick, status_prefix, iu->fullname);
    305311                l = l->next;
    306312        }
Note: See TracChangeset for help on using the changeset viewer.