Changeset 0ef1c92


Ignore:
Timestamp:
2015-09-11T02:31:10Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
dc96e6e
Parents:
34d16d5
git-author:
dequis <dx@…> (27-07-15 05:14:09)
git-committer:
dequis <dx@…> (11-09-15 02:31:10)
Message:

Initial implementation of ircv3 capability negotiation

Mostly no-op for now. Puts registration on hold, supports the basic
commands, and NAKs everything

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    r34d16d5 r0ef1c92  
    727727int irc_check_login(irc_t *irc)
    728728{
    729         if (irc->user->user && irc->user->nick) {
     729        if (irc->user->user && irc->user->nick && !(irc->status & USTATUS_CAP_PENDING)) {
    730730                if (global.conf->authmode == AUTHMODE_CLOSED && !(irc->status & USTATUS_AUTHORIZED)) {
    731731                        irc_send_num(irc, 464, ":This server is password-protected.");
  • irc.h

    r34d16d5 r0ef1c92  
    4949        USTATUS_SHUTDOWN = 8,   /* Now used to indicate we're shutting down.
    5050                                   Currently just blocks irc_vawrite(). */
     51        USTATUS_CAP_PENDING = 16,
    5152
    5253        /* Not really status stuff, but other kinds of flags: For slightly
     
    331332                                     irc_channel_user_flags_t old_flags, irc_channel_user_flags_t new_flags);
    332333void irc_send_invite(irc_user_t *iu, irc_channel_t *ic);
     334void irc_send_cap(irc_t *irc, char *subcommand, char *body);
    333335
    334336/* irc_user.c */
  • irc_commands.c

    r34d16d5 r0ef1c92  
    2828#include "help.h"
    2929#include "ipc.h"
     30
     31static void irc_cmd_cap(irc_t *irc, char **cmd)
     32{
     33        if (!(irc->status & USTATUS_LOGGED_IN)) {
     34                /* Put registration on hold until CAP END */
     35                irc->status |= USTATUS_CAP_PENDING;
     36        }
     37
     38        if (g_strcasecmp(cmd[1], "LS") == 0) {
     39                /* gboolean irc302 = (g_strcmp0(cmd[2], "302") == 0); */
     40                irc_send_cap(irc, "LS", "");
     41
     42        } else if (g_strcasecmp(cmd[1], "LIST") == 0) {
     43                irc_send_cap(irc, "LIST", "");
     44
     45        } else if (g_strcasecmp(cmd[1], "REQ") == 0) {
     46                irc_send_cap(irc, "NAK", cmd[2] ? : "");
     47
     48        } else if (g_strcasecmp(cmd[1], "END") == 0) {
     49                irc->status &= ~USTATUS_CAP_PENDING;
     50                irc_check_login(irc);
     51
     52        } else {
     53                irc_send_num(irc, 410, "%s :Invalid CAP command", cmd[1]);
     54        }
     55
     56}
    3057
    3158static void irc_cmd_pass(irc_t *irc, char **cmd)
     
    685712
    686713static const command_t irc_commands[] = {
     714        { "cap",         1, irc_cmd_cap,         0 },
    687715        { "pass",        1, irc_cmd_pass,        0 },
    688716        { "user",        4, irc_cmd_user,        IRC_CMD_PRE_LOGIN },
  • irc_send.c

    r34d16d5 r0ef1c92  
    428428                  iu->nick, iu->user, iu->host, irc->user->nick, ic->name);
    429429}
     430
     431void irc_send_cap(irc_t *irc, char *subcommand, char *body)
     432{
     433        char *nick = irc->user->nick ? : "*";
     434
     435        irc_write(irc, ":%s CAP %s %s :%s", irc->root->host, nick, subcommand, body);
     436}
Note: See TracChangeset for help on using the changeset viewer.