mirror of
https://github.com/moparisthebest/hexchat
synced 2024-11-22 17:22:18 -05:00
Use macros instead of raw numbers for login type
This commit is contained in:
parent
2c15270be1
commit
83107ee222
@ -1373,12 +1373,15 @@ static int
|
||||
inbound_nickserv_login (server *serv)
|
||||
{
|
||||
/* this could grow ugly, but let's hope there won't be new NickServ types */
|
||||
if (serv->loginmethod >= 1 && serv->loginmethod <= 5)
|
||||
switch (serv->loginmethod)
|
||||
{
|
||||
case LOGIN_MSG_NICKSERV:
|
||||
case LOGIN_NICKSERV:
|
||||
case LOGIN_NS:
|
||||
case LOGIN_MSG_NS:
|
||||
case LOGIN_AUTH:
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ irc_login (server *serv, char *user, char *realname)
|
||||
{
|
||||
tcp_sendf (serv, "CAP LS\r\n"); /* start with CAP LS as Charybdis sasl.txt suggests */
|
||||
|
||||
if (serv->password[0] && serv->loginmethod == 7)
|
||||
if (serv->password[0] && serv->loginmethod == LOGIN_PASS)
|
||||
{
|
||||
tcp_sendf (serv, "PASS %s\r\n", serv->password);
|
||||
}
|
||||
@ -67,19 +67,21 @@ irc_nickserv (server *serv, char *cmd, char *arg1, char *arg2, char *arg3)
|
||||
/* are all ircd authors idiots? */
|
||||
switch (serv->loginmethod)
|
||||
{
|
||||
case 1:
|
||||
case LOGIN_MSG_NICKSERV:
|
||||
tcp_sendf (serv, "PRIVMSG NICKSERV :%s %s%s%s\r\n", cmd, arg1, arg2, arg3);
|
||||
break;
|
||||
case 2:
|
||||
case LOGIN_NICKSERV:
|
||||
tcp_sendf (serv, "NICKSERV %s %s%s%s\r\n", cmd, arg1, arg2, arg3);
|
||||
break;
|
||||
case 3:
|
||||
#if 0
|
||||
case LOGIN_NS:
|
||||
tcp_sendf (serv, "NS %s %s%s%s\r\n", cmd, arg1, arg2, arg3);
|
||||
break;
|
||||
case 4:
|
||||
#endif
|
||||
case LOGIN_MSG_NS:
|
||||
tcp_sendf (serv, "PRIVMSG NS :%s %s%s%s\r\n", cmd, arg1, arg2, arg3);
|
||||
break;
|
||||
case 5:
|
||||
case LOGIN_AUTH:
|
||||
/* why couldn't QuakeNet implement one of the existing ones? */
|
||||
tcp_sendf (serv, "AUTH %s %s\r\n", arg1, arg2);
|
||||
}
|
||||
@ -88,7 +90,7 @@ irc_nickserv (server *serv, char *cmd, char *arg1, char *arg2, char *arg3)
|
||||
static void
|
||||
irc_ns_identify (server *serv, char *pass)
|
||||
{
|
||||
if (serv->loginmethod == 5) /* QuakeNet needs to do everything in its own ways... */
|
||||
if (serv->loginmethod == LOGIN_AUTH) /* QuakeNet needs to do everything in its own ways... */
|
||||
{
|
||||
irc_nickserv (serv, "", serv->nick, pass, "");
|
||||
}
|
||||
@ -101,7 +103,7 @@ irc_ns_identify (server *serv, char *pass)
|
||||
static void
|
||||
irc_ns_ghost (server *serv, char *usname, char *pass)
|
||||
{
|
||||
if (serv->loginmethod != 5)
|
||||
if (serv->loginmethod != LOGIN_AUTH)
|
||||
{
|
||||
irc_nickserv (serv, "GHOST", usname, " ", pass);
|
||||
}
|
||||
@ -1276,7 +1278,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[])
|
||||
want_cap = 1;
|
||||
}
|
||||
/* if the SASL password is set AND auth mode is set to SASL, request SASL auth */
|
||||
if (strstr (word_eol[5], "sasl") != 0 && strlen (sess->server->password) != 0 && serv->loginmethod == 6)
|
||||
if (strstr (word_eol[5], "sasl") != 0 && strlen (sess->server->password) != 0 && serv->loginmethod == LOGIN_SASL)
|
||||
{
|
||||
strcat (buffer, "sasl ");
|
||||
want_cap = 1;
|
||||
|
@ -167,7 +167,7 @@ static const struct defaultserver def[] =
|
||||
{0, "irc.criten.net"},
|
||||
{0, "irc.eu.criten.net"},
|
||||
|
||||
{"DALnet", 0, 0, 0, 2},
|
||||
{"DALnet", 0},
|
||||
{0, "irc.dal.net"},
|
||||
{0, "irc.eu.dal.net"},
|
||||
|
||||
@ -245,7 +245,7 @@ static const struct defaultserver def[] =
|
||||
{0, "irc.ggn.net"},
|
||||
{0, "irc.vendetta.com"},
|
||||
|
||||
{"freenode", 0, "#hexchat", 0, 6},
|
||||
{"freenode", 0, "#hexchat", 0, LOGIN_SASL},
|
||||
#ifdef USE_OPENSSL
|
||||
{0, "irc.freenode.net/+6697"},
|
||||
#endif
|
||||
@ -263,7 +263,7 @@ static const struct defaultserver def[] =
|
||||
/* {0, "sprynet.us.galaxynet.org"},
|
||||
{0, "atlanta.ga.us.galaxynet.org"},*/
|
||||
|
||||
{"GameSurge", 0, 0, 0, 2},
|
||||
{"GameSurge", 0},
|
||||
{0, "irc.gamesurge.net"},
|
||||
|
||||
/* {"GamesNET", 0},
|
||||
@ -426,7 +426,7 @@ static const struct defaultserver def[] =
|
||||
{0, "nfsi.ptnet.org"},
|
||||
{0, "fctunl.ptnet.org"},
|
||||
|
||||
{"QuakeNet", 0, 0, 0, 5},
|
||||
{"QuakeNet", 0, 0, 0, LOGIN_AUTH},
|
||||
{0, "irc.quakenet.org"},
|
||||
{0, "irc.se.quakenet.org"},
|
||||
{0, "irc.dk.quakenet.org"},
|
||||
@ -460,7 +460,7 @@ static const struct defaultserver def[] =
|
||||
{"Rizon", 0},
|
||||
{0, "irc.rizon.net"},
|
||||
|
||||
{"RusNet", 0, 0, "KOI8-R (Cyrillic)", 2},
|
||||
{"RusNet", 0, 0, "KOI8-R (Cyrillic)"},
|
||||
{0, "irc.tomsk.net"},
|
||||
{0, "irc.rinet.ru"},
|
||||
{0, "irc.run.net"},
|
||||
@ -545,7 +545,7 @@ static const struct defaultserver def[] =
|
||||
{0, "us.undernet.org"},
|
||||
{0, "eu.undernet.org"},
|
||||
|
||||
{"UniBG", 0, 0, 0, 4},
|
||||
{"UniBG", 0, 0, 0, LOGIN_MSG_NS},
|
||||
{0, "irc.lirex.com"},
|
||||
{0, "irc.naturella.com"},
|
||||
{0, "irc.spnet.net"},
|
||||
@ -638,7 +638,7 @@ servlist_connect (session *sess, ircnet *net, gboolean join)
|
||||
return;
|
||||
ircserv = list->data;
|
||||
|
||||
/* incase a protocol switch is added to the servlist gui */
|
||||
/* in case a protocol switch is added to the servlist gui */
|
||||
server_fill_her_up (sess->server);
|
||||
|
||||
if (join)
|
||||
@ -661,7 +661,7 @@ servlist_connect (session *sess, ircnet *net, gboolean join)
|
||||
}
|
||||
else
|
||||
{
|
||||
serv->loginmethod = 7; /* Use server password by default. If we had a NickServ password, it'd be set to 2 already. */
|
||||
serv->loginmethod = LOGIN_DEFAULT_REAL;
|
||||
}
|
||||
|
||||
serv->password[0] = 0;
|
||||
@ -1264,7 +1264,7 @@ servlist_load (void)
|
||||
net->pass = strdup (buf + 2);
|
||||
if (!net->logintype)
|
||||
{
|
||||
net->logintype = 6;
|
||||
net->logintype = LOGIN_SASL;
|
||||
}
|
||||
}
|
||||
case 'B':
|
||||
@ -1273,7 +1273,7 @@ servlist_load (void)
|
||||
net->pass = strdup (buf + 2);
|
||||
if (!net->logintype)
|
||||
{
|
||||
net->logintype = 2;
|
||||
net->logintype = LOGIN_NICKSERV;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,17 @@ extern GSList *network_list;
|
||||
#define FLAG_FAVORITE 64
|
||||
#define FLAG_COUNT 7
|
||||
|
||||
/* Login methods. Use server password by default - if we had a NickServ password, it'd be set to 2 already by servlist_load() */
|
||||
#define LOGIN_DEFAULT_REAL LOGIN_PASS /* this is to set the default login method for unknown servers */
|
||||
#define LOGIN_DEFAULT 0 /* this is for the login type dropdown, doesn't serve any other purpose */
|
||||
#define LOGIN_MSG_NICKSERV 1
|
||||
#define LOGIN_NICKSERV 2
|
||||
#define LOGIN_NS 3
|
||||
#define LOGIN_MSG_NS 4
|
||||
#define LOGIN_AUTH 5
|
||||
#define LOGIN_SASL 6
|
||||
#define LOGIN_PASS 7
|
||||
|
||||
/* DEFAULT_CHARSET is already defined in wingdi.h */
|
||||
#define IRC_DEFAULT_CHARSET "UTF-8 (Unicode)"
|
||||
|
||||
|
@ -116,16 +116,16 @@ static const char *pages[]=
|
||||
*/
|
||||
static int login_types_conf[] =
|
||||
{
|
||||
0, /* default - we don't use this but it makes indexing consistent with login_types[] so it's nice */
|
||||
6, /* SASL */
|
||||
7, /* /pass */
|
||||
1, /* /msg NickServ */
|
||||
2, /* /NickServ */
|
||||
LOGIN_DEFAULT, /* default entry - we don't use this but it makes indexing consistent with login_types[] so it's nice */
|
||||
LOGIN_SASL,
|
||||
LOGIN_PASS,
|
||||
LOGIN_MSG_NICKSERV,
|
||||
LOGIN_NICKSERV,
|
||||
#if 0
|
||||
3, /* /NS */
|
||||
LOGIN_NS,
|
||||
#endif
|
||||
4, /* /msg NS */
|
||||
5, /* /auth */
|
||||
LOGIN_MSG_NS,
|
||||
LOGIN_AUTH,
|
||||
};
|
||||
|
||||
static const char *login_types[]=
|
||||
|
Loading…
Reference in New Issue
Block a user