2011-02-23 22:14:30 -05:00
|
|
|
/* X-Chat
|
|
|
|
* Copyright (C) 1998 Peter Zelezny.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-12-23 14:36:54 -05:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2011-02-23 22:14:30 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2011-12-11 11:34:02 -05:00
|
|
|
#ifndef WIN32
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2012-10-24 15:33:02 -04:00
|
|
|
#include "hexchat.h"
|
2011-02-23 22:14:30 -05:00
|
|
|
#include "cfgfiles.h"
|
|
|
|
#include "fe.h"
|
|
|
|
#include "server.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "util.h" /* token_foreach */
|
2012-10-24 15:33:02 -04:00
|
|
|
#include "hexchatc.h"
|
2011-02-23 22:14:30 -05:00
|
|
|
|
|
|
|
#include "servlist.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct defaultserver
|
|
|
|
{
|
|
|
|
char *network;
|
|
|
|
char *host;
|
|
|
|
char *channel;
|
|
|
|
char *charset;
|
2013-05-10 17:52:47 -04:00
|
|
|
int loginmode; /* default authentication type */
|
2013-05-19 06:15:31 -04:00
|
|
|
char *connectcmd; /* default connect command - should only be used for rare login types, paired with LOGIN_CUSTOM */
|
2015-01-20 03:03:45 -05:00
|
|
|
gboolean ssl;
|
2011-02-23 22:14:30 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct defaultserver def[] =
|
|
|
|
{
|
|
|
|
{"2600net", 0},
|
|
|
|
{0, "irc.2600.net"},
|
|
|
|
|
2013-07-02 10:35:06 -04:00
|
|
|
{"2ch", 0, 0, "iso-2022-jp", 0, 0},
|
2014-06-03 17:20:01 -04:00
|
|
|
{0, "irc.2ch.sc"},
|
|
|
|
{0, "irc.nurs.or.jp"},
|
2013-07-03 00:42:48 -04:00
|
|
|
{0, "irc.juggler.jp"},
|
2013-07-02 10:35:06 -04:00
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"AccessIRC", 0},
|
|
|
|
{0, "irc.accessirc.net"},
|
|
|
|
|
|
|
|
{"AfterNET", 0},
|
|
|
|
{0, "irc.afternet.org"},
|
|
|
|
|
|
|
|
{"Aitvaras", 0},
|
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
{0, "irc.data.lt/+6668"},
|
2014-06-27 19:19:13 -04:00
|
|
|
{0, "irc.omnitel.net/+6668"},
|
|
|
|
{0, "irc.ktu.lt/+6668"},
|
|
|
|
{0, "irc.kis.lt/+6668"},
|
|
|
|
{0, "irc.vub.lt/+6668"},
|
2011-02-23 22:14:30 -05:00
|
|
|
#endif
|
|
|
|
{0, "irc.data.lt"},
|
|
|
|
{0, "irc.omnitel.net"},
|
|
|
|
{0, "irc.ktu.lt"},
|
|
|
|
{0, "irc.kis.lt"},
|
2014-06-27 19:19:13 -04:00
|
|
|
{0, "irc.vub.lt"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Anthrochat", 0, 0, 0, 0, 0, TRUE},
|
2014-03-01 16:33:29 -05:00
|
|
|
{0, "irc.anthrochat.net"},
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"ARCNet", 0},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "arcnet-irc.org"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"AthemeNet", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2015-01-19 11:31:42 -05:00
|
|
|
{0, "irc.atheme.org"},
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"AustNet", 0},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.austnet.org"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
|
|
|
{"AzzurraNet", 0},
|
|
|
|
{0, "irc.azzurra.org"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Canternet", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2014-02-02 17:08:32 -05:00
|
|
|
{0, "irc.canternet.org"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Chat4all", 0, 0, 0, 0, 0, TRUE},
|
2012-09-01 11:01:01 -04:00
|
|
|
{0, "irc.chat4all.org"},
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"ChattingAway", 0},
|
|
|
|
{0, "irc.chattingaway.com"},
|
|
|
|
|
2013-10-17 05:00:40 -04:00
|
|
|
{"ChatJunkies", 0},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "irc.chatjunkies.org"},
|
|
|
|
|
|
|
|
{"ChatNet", 0},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.chatnet.org"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
|
|
|
{"ChatSpike", 0},
|
|
|
|
{0, "irc.chatspike.net"},
|
|
|
|
|
|
|
|
{"Criten", 0},
|
|
|
|
{0, "irc.criten.net"},
|
|
|
|
|
2013-05-13 07:22:25 -04:00
|
|
|
{"DALnet", 0},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "irc.dal.net"},
|
|
|
|
|
|
|
|
{"Dark-Tou-Net", 0},
|
|
|
|
{0, "irc.d-t-net.de"},
|
|
|
|
|
2013-10-17 05:16:27 -04:00
|
|
|
{"DarkMyst", 0, 0, 0, LOGIN_SASL},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "irc.darkmyst.org"},
|
|
|
|
|
|
|
|
{"DeepIRC", 0},
|
|
|
|
{0, "irc.deepirc.net"},
|
|
|
|
|
|
|
|
{"DeltaAnime", 0},
|
|
|
|
{0, "irc.deltaanime.net"},
|
|
|
|
|
|
|
|
{"EFnet", 0},
|
|
|
|
{0, "irc.blackened.com"},
|
|
|
|
{0, "irc.Prison.NET"},
|
|
|
|
{0, "irc.Qeast.net"},
|
|
|
|
{0, "irc.efnet.pl"},
|
|
|
|
{0, "irc.lightning.net"},
|
|
|
|
{0, "irc.servercentral.net"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"ElectroCode", 0, 0, 0, 0, 0, TRUE},
|
2014-03-07 19:16:42 -05:00
|
|
|
{0, "irc.electrocode.net"},
|
2013-10-13 10:46:36 -04:00
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"EnterTheGame", 0},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.enterthegame.com"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"EntropyNet", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2012-07-31 05:38:08 -04:00
|
|
|
{0, "irc.entropynet.net"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"EsperNet", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2012-09-09 08:36:21 -04:00
|
|
|
{0, "irc.esper.net"},
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"EUIrc", 0},
|
|
|
|
{0, "irc.euirc.net"},
|
|
|
|
|
|
|
|
{"EuropNet", 0},
|
|
|
|
{0, "irc.europnet.org"},
|
|
|
|
|
|
|
|
{"FDFNet", 0},
|
|
|
|
{0, "irc.fdfnet.net"},
|
|
|
|
|
2013-10-17 05:16:27 -04:00
|
|
|
{"FEFNet", 0, 0, 0, LOGIN_SASL},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "irc.fef.net"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"freenode", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2013-06-18 21:38:10 -04:00
|
|
|
{0, "chat.freenode.net"},
|
2013-08-08 12:01:49 -04:00
|
|
|
/* irc. points to chat. but many users and urls still reference it */
|
|
|
|
{0, "irc.freenode.net"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Furnet", 0, 0, 0, 0, 0, TRUE},
|
2014-03-01 16:33:29 -05:00
|
|
|
{0, "irc.furnet.org"},
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"GalaxyNet", 0},
|
|
|
|
{0, "irc.galaxynet.org"},
|
|
|
|
|
2013-05-13 07:22:25 -04:00
|
|
|
{"GameSurge", 0},
|
2012-12-19 22:38:34 -05:00
|
|
|
{0, "irc.gamesurge.net"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"GeeksIRC", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2014-07-14 20:24:15 -04:00
|
|
|
{0, "irc.geeksirc.net"},
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"GeekShed", 0},
|
|
|
|
{0, "irc.geekshed.net"},
|
|
|
|
|
|
|
|
{"German-Elite", 0},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.german-elite.net"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
2012-10-03 05:29:59 -04:00
|
|
|
{"GIMPNet", 0},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "irc.gimp.org"},
|
2012-10-03 05:29:59 -04:00
|
|
|
{0, "irc.gnome.org"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
|
|
|
{"Hashmark", 0},
|
|
|
|
{0, "irc.hashmark.net"},
|
|
|
|
|
|
|
|
{"IdleMonkeys", 0},
|
|
|
|
{0, "irc.idlemonkeys.net"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"IndirectIRC", 0, 0, 0, 0, 0, TRUE},
|
2012-09-23 17:17:20 -04:00
|
|
|
{0, "irc.indirectirc.com"},
|
2013-11-19 17:16:57 -05:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Interlinked", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2013-11-19 17:16:57 -05:00
|
|
|
{0, "irc.interlinked.me"},
|
2012-09-23 17:17:20 -04:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"IRC4Fun", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2014-07-14 20:24:15 -04:00
|
|
|
{0, "irc.irc4fun.net"},
|
|
|
|
|
2012-10-06 10:44:31 -04:00
|
|
|
{"IRCHighWay", 0},
|
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
{0, "irc.irchighway.net/+9999"},
|
|
|
|
#endif
|
|
|
|
{0, "irc.irchighway.net"},
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"IrcLink", 0},
|
|
|
|
{0, "irc.irclink.net"},
|
|
|
|
|
|
|
|
{"IRCNet", 0},
|
2013-05-05 23:53:07 -04:00
|
|
|
{0, "open.ircnet.net"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
|
|
|
{"Irctoo.net", 0},
|
|
|
|
{0, "irc.irctoo.net"},
|
|
|
|
|
2012-09-23 17:17:20 -04:00
|
|
|
{"iZ-smart.net", 0},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.iz-smart.net"},
|
2012-09-23 17:17:20 -04:00
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"Krstarica", 0},
|
|
|
|
{0, "irc.krstarica.com"},
|
|
|
|
|
2012-07-31 05:33:15 -04:00
|
|
|
#ifdef USE_OPENSSL
|
2011-02-23 22:14:30 -05:00
|
|
|
{"LinkNet", 0},
|
2012-07-31 05:33:15 -04:00
|
|
|
{0, "irc.link-net.org/+7000"},
|
|
|
|
#endif
|
2011-02-23 22:14:30 -05:00
|
|
|
|
|
|
|
{"MindForge", 0},
|
|
|
|
{0, "irc.mindforge.org"},
|
|
|
|
|
|
|
|
{"MIXXnet", 0},
|
|
|
|
{0, "irc.mixxnet.net"},
|
|
|
|
|
2012-12-20 08:49:39 -05:00
|
|
|
{"Moznet", 0},
|
|
|
|
{0, "irc.mozilla.org"},
|
2013-08-15 17:59:41 -04:00
|
|
|
|
|
|
|
{"ObsidianIRC", 0},
|
|
|
|
{0, "irc.obsidianirc.net"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
2013-10-17 05:16:27 -04:00
|
|
|
{"Oceanius", 0, 0, 0, LOGIN_SASL},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "irc.oceanius.com"},
|
|
|
|
|
|
|
|
{"OFTC", 0},
|
|
|
|
{0, "irc.oftc.net"},
|
|
|
|
|
|
|
|
{"OtherNet", 0},
|
|
|
|
{0, "irc.othernet.org"},
|
|
|
|
|
|
|
|
{"OzNet", 0},
|
|
|
|
{0, "irc.oz.org"},
|
|
|
|
|
|
|
|
{"PIRC.PL", 0},
|
|
|
|
{0, "irc.pirc.pl"},
|
2013-05-25 00:01:06 -04:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"PonyChat", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2013-05-25 00:01:06 -04:00
|
|
|
{0, "irc.ponychat.net"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
2011-05-30 14:27:08 -04:00
|
|
|
{"PTNet.org", 0},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.ptnet.org"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
2013-05-16 19:39:28 -04:00
|
|
|
{"QuakeNet", 0, 0, 0, LOGIN_CHALLENGEAUTH},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "irc.quakenet.org"},
|
|
|
|
|
|
|
|
{"Rizon", 0},
|
|
|
|
{0, "irc.rizon.net"},
|
|
|
|
|
2013-05-13 07:22:25 -04:00
|
|
|
{"RusNet", 0, 0, "KOI8-R (Cyrillic)"},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "irc.tomsk.net"},
|
|
|
|
{0, "irc.run.net"},
|
|
|
|
{0, "irc.ru"},
|
|
|
|
{0, "irc.lucky.net"},
|
|
|
|
|
|
|
|
{"SceneNet", 0},
|
|
|
|
{0, "irc.scene.org"},
|
|
|
|
|
|
|
|
{"SeilEn.de", 0},
|
|
|
|
{0, "irc.seilen.de"},
|
|
|
|
|
2013-06-06 22:58:34 -04:00
|
|
|
{"Serenity-IRC", 0},
|
|
|
|
{0, "irc.serenity-irc.net"},
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"SlashNET", 0},
|
|
|
|
{0, "irc.slashnet.org"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Snoonet", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.snoonet.org"},
|
2012-08-05 22:51:24 -04:00
|
|
|
|
2013-03-26 20:45:22 -04:00
|
|
|
{"Snyde", 0},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.snyde.net"},
|
2013-03-26 20:45:22 -04:00
|
|
|
|
2012-08-05 23:22:25 -04:00
|
|
|
{"Sohbet.Net", 0},
|
|
|
|
{0, "irc.sohbet.net"},
|
|
|
|
|
|
|
|
{"SolidIRC", 0},
|
|
|
|
{0, "irc.solidirc.com"},
|
|
|
|
|
2013-10-17 05:16:27 -04:00
|
|
|
{"SorceryNet", 0, 0, 0, LOGIN_SASL},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.sorcery.net"},
|
2013-03-27 03:14:18 -04:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"SpotChat", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.spotchat.org"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
|
|
|
{"StarChat", 0},
|
|
|
|
{0, "irc.starchat.net"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Station51", 0, 0, 0, 0, 0, TRUE},
|
2013-01-23 17:05:43 -05:00
|
|
|
{0, "irc.station51.net"},
|
2014-01-04 08:49:40 -05:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"StormBit", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2014-01-04 08:49:40 -05:00
|
|
|
{0, "irc.stormbit.net"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"SwiftIRC", 0, 0, 0, 0, 0, TRUE},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.swiftirc.net"},
|
2012-10-15 04:40:39 -04:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"synIRC", 0, 0, 0, 0, 0, TRUE},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.synirc.net"},
|
2014-01-30 17:23:57 -05:00
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Techtronix", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2015-01-20 02:19:18 -05:00
|
|
|
{0, "irc.techtronix.net"},
|
2013-10-27 22:05:47 -04:00
|
|
|
|
2013-10-17 05:16:27 -04:00
|
|
|
{"TinyCrab", 0, 0, 0, LOGIN_SASL},
|
2013-08-21 07:36:53 -04:00
|
|
|
{0, "irc.tinycrab.net"},
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{"TURLINet", 0},
|
|
|
|
{0, "irc.turli.net"},
|
|
|
|
{0, "irc.servx.ru"},
|
|
|
|
{0, "irc.gavnos.ru"},
|
|
|
|
|
2013-05-19 06:15:31 -04:00
|
|
|
{"UnderNet", 0, 0, 0, LOGIN_CUSTOM, "MSG x@channels.undernet.org login %u %p"},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "us.undernet.org"},
|
|
|
|
|
2013-05-19 06:15:31 -04:00
|
|
|
{"UniBG", 0, 0, 0, LOGIN_CUSTOM, "MSG NS IDENTIFY %p"},
|
2011-02-23 22:14:30 -05:00
|
|
|
{0, "irc.lirex.com"},
|
|
|
|
{0, "irc.naturella.com"},
|
|
|
|
{0, "irc.techno-link.com"},
|
2013-05-31 19:12:21 -04:00
|
|
|
|
2013-10-17 05:16:27 -04:00
|
|
|
{"ValleyNode", 0, 0, 0, LOGIN_SASL},
|
2013-05-31 19:12:21 -04:00
|
|
|
{0, "irc.valleynode.net"},
|
2011-02-23 22:14:30 -05:00
|
|
|
|
|
|
|
{"Worldnet", 0},
|
|
|
|
{0, "irc.worldnet.net"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Windfyre", 0, 0, 0, 0, 0, TRUE},
|
2012-07-31 05:41:07 -04:00
|
|
|
{0, "irc.windfyre.net"},
|
|
|
|
|
2015-01-20 03:03:45 -05:00
|
|
|
{"Xertion", 0, 0, 0, LOGIN_SASL, 0, TRUE},
|
2014-04-10 23:05:04 -04:00
|
|
|
{0, "irc.xertion.org"},
|
2014-04-10 22:59:04 -04:00
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
{0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
GSList *network_list = 0;
|
|
|
|
|
2013-05-12 00:16:26 -04:00
|
|
|
#if !GLIB_CHECK_VERSION(2,34,0)
|
|
|
|
#define g_slist_copy_deep servlist_slist_copy_deep
|
|
|
|
/* FIXME copy-paste from gslist.c, should be dumped sometime */
|
|
|
|
static GSList*
|
|
|
|
servlist_slist_copy_deep (GSList *list, GCopyFunc func, gpointer user_data)
|
|
|
|
{
|
|
|
|
GSList *new_list = NULL;
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
GSList *last;
|
|
|
|
|
|
|
|
new_list = g_slice_new (GSList);
|
|
|
|
if (func)
|
|
|
|
new_list->data = func (list->data, user_data);
|
|
|
|
else
|
|
|
|
new_list->data = list->data;
|
|
|
|
last = new_list;
|
|
|
|
list = list->next;
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
last->next = g_slice_new (GSList);
|
|
|
|
last = last->next;
|
|
|
|
if (func)
|
|
|
|
last->data = func (list->data, user_data);
|
|
|
|
else
|
|
|
|
last->data = list->data;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
last->next = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_list;
|
|
|
|
}
|
|
|
|
#endif
|
2011-02-23 22:14:30 -05:00
|
|
|
|
2013-05-14 10:40:32 -04:00
|
|
|
favchannel *
|
|
|
|
servlist_favchan_copy (favchannel *fav)
|
|
|
|
{
|
|
|
|
favchannel *newfav;
|
|
|
|
|
2014-12-28 06:37:25 -05:00
|
|
|
newfav = g_new (favchannel, 1);
|
2013-05-14 10:40:32 -04:00
|
|
|
newfav->name = g_strdup (fav->name);
|
|
|
|
newfav->key = g_strdup (fav->key); /* g_strdup() can handle NULLs so no need to check it */
|
|
|
|
|
|
|
|
return newfav;
|
|
|
|
}
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
void
|
|
|
|
servlist_connect (session *sess, ircnet *net, gboolean join)
|
|
|
|
{
|
|
|
|
ircserver *ircserv;
|
|
|
|
GSList *list;
|
|
|
|
char *port;
|
|
|
|
server *serv;
|
|
|
|
|
|
|
|
if (!sess)
|
|
|
|
sess = new_ircwindow (NULL, NULL, SESS_SERVER, TRUE);
|
|
|
|
|
|
|
|
serv = sess->server;
|
|
|
|
|
|
|
|
/* connect to the currently selected Server-row */
|
|
|
|
list = g_slist_nth (net->servlist, net->selected);
|
|
|
|
if (!list)
|
|
|
|
list = net->servlist;
|
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
ircserv = list->data;
|
|
|
|
|
2013-05-13 07:22:25 -04:00
|
|
|
/* in case a protocol switch is added to the servlist gui */
|
2011-02-23 22:14:30 -05:00
|
|
|
server_fill_her_up (sess->server);
|
|
|
|
|
|
|
|
if (join)
|
|
|
|
{
|
|
|
|
sess->willjoinchannel[0] = 0;
|
|
|
|
|
2013-05-11 23:44:32 -04:00
|
|
|
if (net->favchanlist)
|
2011-02-23 22:14:30 -05:00
|
|
|
{
|
2013-05-11 23:44:32 -04:00
|
|
|
if (serv->favlist)
|
|
|
|
{
|
2013-05-14 10:52:16 -04:00
|
|
|
g_slist_free_full (serv->favlist, (GDestroyNotify) servlist_favchan_free);
|
2013-05-11 23:44:32 -04:00
|
|
|
}
|
2013-05-14 10:40:32 -04:00
|
|
|
serv->favlist = g_slist_copy_deep (net->favchanlist, (GCopyFunc) servlist_favchan_copy, NULL);
|
2011-02-23 22:14:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-10 17:52:47 -04:00
|
|
|
if (net->logintype)
|
2013-04-28 15:24:53 -04:00
|
|
|
{
|
2013-05-10 17:52:47 -04:00
|
|
|
serv->loginmethod = net->logintype;
|
2013-04-28 15:24:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-13 07:22:25 -04:00
|
|
|
serv->loginmethod = LOGIN_DEFAULT_REAL;
|
2013-04-28 15:24:53 -04:00
|
|
|
}
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
serv->password[0] = 0;
|
2012-10-25 10:17:21 -04:00
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
if (net->pass)
|
2012-10-25 10:17:21 -04:00
|
|
|
{
|
2011-02-23 22:14:30 -05:00
|
|
|
safe_strcpy (serv->password, net->pass, sizeof (serv->password));
|
2012-10-25 10:17:21 -04:00
|
|
|
}
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
if (net->flags & FLAG_USE_GLOBAL)
|
|
|
|
{
|
2012-10-22 08:50:36 -04:00
|
|
|
strcpy (serv->nick, prefs.hex_irc_nick1);
|
2012-10-25 10:17:21 -04:00
|
|
|
}
|
|
|
|
else
|
2011-02-23 22:14:30 -05:00
|
|
|
{
|
|
|
|
if (net->nick)
|
|
|
|
strcpy (serv->nick, net->nick);
|
|
|
|
}
|
|
|
|
|
|
|
|
serv->dont_use_proxy = (net->flags & FLAG_USE_PROXY) ? FALSE : TRUE;
|
|
|
|
|
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
serv->use_ssl = (net->flags & FLAG_USE_SSL) ? TRUE : FALSE;
|
|
|
|
serv->accept_invalid_cert =
|
|
|
|
(net->flags & FLAG_ALLOW_INVALID) ? TRUE : FALSE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
serv->network = net;
|
|
|
|
|
|
|
|
port = strrchr (ircserv->hostname, '/');
|
|
|
|
if (port)
|
|
|
|
{
|
|
|
|
*port = 0;
|
|
|
|
|
|
|
|
/* support "+port" to indicate SSL (like mIRC does) */
|
|
|
|
if (port[1] == '+')
|
|
|
|
{
|
|
|
|
#ifdef USE_OPENSSL
|
|
|
|
serv->use_ssl = TRUE;
|
|
|
|
#endif
|
|
|
|
serv->connect (serv, ircserv->hostname, atoi (port + 2), FALSE);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
serv->connect (serv, ircserv->hostname, atoi (port + 1), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
*port = '/';
|
|
|
|
} else
|
|
|
|
serv->connect (serv, ircserv->hostname, -1, FALSE);
|
|
|
|
|
|
|
|
server_set_encoding (serv, net->encoding);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
servlist_connect_by_netname (session *sess, char *network, gboolean join)
|
|
|
|
{
|
|
|
|
ircnet *net;
|
|
|
|
GSList *list = network_list;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
net = list->data;
|
|
|
|
|
2012-06-16 07:01:47 -04:00
|
|
|
if (g_ascii_strcasecmp (net->name, network) == 0)
|
2011-02-23 22:14:30 -05:00
|
|
|
{
|
|
|
|
servlist_connect (sess, net, join);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
servlist_have_auto (void)
|
|
|
|
{
|
|
|
|
GSList *list = network_list;
|
|
|
|
ircnet *net;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
net = list->data;
|
|
|
|
|
|
|
|
if (net->flags & FLAG_AUTO_CONNECT)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
servlist_auto_connect (session *sess)
|
|
|
|
{
|
|
|
|
GSList *list = network_list;
|
|
|
|
ircnet *net;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
net = list->data;
|
|
|
|
|
|
|
|
if (net->flags & FLAG_AUTO_CONNECT)
|
|
|
|
{
|
|
|
|
servlist_connect (sess, net, TRUE);
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
servlist_cycle_cb (server *serv)
|
|
|
|
{
|
|
|
|
if (serv->network)
|
|
|
|
{
|
|
|
|
PrintTextf (serv->server_session,
|
|
|
|
_("Cycling to next server in %s...\n"), ((ircnet *)serv->network)->name);
|
|
|
|
servlist_connect (serv->server_session, serv->network, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
servlist_cycle (server *serv)
|
|
|
|
{
|
|
|
|
ircnet *net;
|
|
|
|
int max, del;
|
|
|
|
|
|
|
|
net = serv->network;
|
|
|
|
if (net)
|
|
|
|
{
|
|
|
|
max = g_slist_length (net->servlist);
|
|
|
|
if (max > 0)
|
|
|
|
{
|
|
|
|
/* try the next server, if that option is on */
|
|
|
|
if (net->flags & FLAG_CYCLE)
|
|
|
|
{
|
|
|
|
net->selected++;
|
|
|
|
if (net->selected >= max)
|
|
|
|
net->selected = 0;
|
|
|
|
}
|
|
|
|
|
2012-10-22 09:55:43 -04:00
|
|
|
del = prefs.hex_net_reconnect_delay * 1000;
|
2011-02-23 22:14:30 -05:00
|
|
|
if (del < 1000)
|
|
|
|
del = 500; /* so it doesn't block the gui */
|
|
|
|
|
|
|
|
if (del)
|
|
|
|
serv->recondelay_tag = fe_timeout_add (del, servlist_cycle_cb, serv);
|
|
|
|
else
|
|
|
|
servlist_connect (serv->server_session, net, TRUE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ircserver *
|
|
|
|
servlist_server_find (ircnet *net, char *name, int *pos)
|
|
|
|
{
|
|
|
|
GSList *list = net->servlist;
|
|
|
|
ircserver *serv;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
serv = list->data;
|
|
|
|
if (strcmp (serv->hostname, name) == 0)
|
|
|
|
{
|
|
|
|
if (pos)
|
2013-05-11 23:44:32 -04:00
|
|
|
{
|
2011-02-23 22:14:30 -05:00
|
|
|
*pos = i;
|
2013-05-11 23:44:32 -04:00
|
|
|
}
|
2011-02-23 22:14:30 -05:00
|
|
|
return serv;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-05-11 23:44:32 -04:00
|
|
|
favchannel *
|
|
|
|
servlist_favchan_find (ircnet *net, char *channel, int *pos)
|
|
|
|
{
|
2013-05-24 16:49:46 -04:00
|
|
|
GSList *list;
|
2013-05-11 23:44:32 -04:00
|
|
|
favchannel *favchan;
|
|
|
|
int i = 0;
|
|
|
|
|
2013-05-24 16:49:46 -04:00
|
|
|
if (net == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
list = net->favchanlist;
|
|
|
|
|
2013-05-11 23:44:32 -04:00
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
favchan = list->data;
|
2014-04-18 20:40:16 -04:00
|
|
|
if (g_ascii_strcasecmp (favchan->name, channel) == 0)
|
2013-05-11 23:44:32 -04:00
|
|
|
{
|
|
|
|
if (pos)
|
|
|
|
{
|
|
|
|
*pos = i;
|
|
|
|
}
|
|
|
|
return favchan;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-05-11 14:06:22 -04:00
|
|
|
commandentry *
|
|
|
|
servlist_command_find (ircnet *net, char *cmd, int *pos)
|
|
|
|
{
|
|
|
|
GSList *list = net->commandlist;
|
|
|
|
commandentry *entry;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
entry = list->data;
|
|
|
|
if (strcmp (entry->command, cmd) == 0)
|
|
|
|
{
|
|
|
|
if (pos)
|
2013-05-11 23:44:32 -04:00
|
|
|
{
|
2013-05-11 14:06:22 -04:00
|
|
|
*pos = i;
|
2013-05-11 23:44:32 -04:00
|
|
|
}
|
2013-05-11 14:06:22 -04:00
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
/* find a network (e.g. (ircnet *) to "FreeNode") from a hostname
|
|
|
|
(e.g. "irc.eu.freenode.net") */
|
|
|
|
|
|
|
|
ircnet *
|
|
|
|
servlist_net_find_from_server (char *server_name)
|
|
|
|
{
|
|
|
|
GSList *list = network_list;
|
|
|
|
GSList *slist;
|
|
|
|
ircnet *net;
|
|
|
|
ircserver *serv;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
net = list->data;
|
|
|
|
|
|
|
|
slist = net->servlist;
|
|
|
|
while (slist)
|
|
|
|
{
|
|
|
|
serv = slist->data;
|
2012-06-16 07:01:47 -04:00
|
|
|
if (g_ascii_strcasecmp (serv->hostname, server_name) == 0)
|
2011-02-23 22:14:30 -05:00
|
|
|
return net;
|
|
|
|
slist = slist->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ircnet *
|
|
|
|
servlist_net_find (char *name, int *pos, int (*cmpfunc) (const char *, const char *))
|
|
|
|
{
|
|
|
|
GSList *list = network_list;
|
|
|
|
ircnet *net;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
net = list->data;
|
|
|
|
if (cmpfunc (net->name, name) == 0)
|
|
|
|
{
|
|
|
|
if (pos)
|
|
|
|
*pos = i;
|
|
|
|
return net;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ircserver *
|
|
|
|
servlist_server_add (ircnet *net, char *name)
|
|
|
|
{
|
|
|
|
ircserver *serv;
|
|
|
|
|
2014-12-28 06:37:25 -05:00
|
|
|
serv = g_new (ircserver, 1);
|
|
|
|
serv->hostname = g_strdup (name);
|
2011-02-23 22:14:30 -05:00
|
|
|
|
|
|
|
net->servlist = g_slist_append (net->servlist, serv);
|
|
|
|
|
|
|
|
return serv;
|
|
|
|
}
|
|
|
|
|
2013-05-11 14:06:22 -04:00
|
|
|
commandentry *
|
|
|
|
servlist_command_add (ircnet *net, char *cmd)
|
|
|
|
{
|
|
|
|
commandentry *entry;
|
|
|
|
|
2014-12-28 06:37:25 -05:00
|
|
|
entry = g_new (commandentry, 1);
|
|
|
|
entry->command = g_strdup (cmd);
|
2013-05-11 14:06:22 -04:00
|
|
|
|
|
|
|
net->commandlist = g_slist_append (net->commandlist, entry);
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
2013-05-15 05:43:38 -04:00
|
|
|
GSList *
|
|
|
|
servlist_favchan_listadd (GSList *chanlist, char *channel, char *key)
|
2013-05-11 23:44:32 -04:00
|
|
|
{
|
|
|
|
favchannel *chan;
|
|
|
|
|
2014-12-28 06:37:25 -05:00
|
|
|
chan = g_new (favchannel, 1);
|
2013-05-15 05:43:38 -04:00
|
|
|
chan->name = g_strdup (channel);
|
|
|
|
chan->key = g_strdup (key);
|
|
|
|
chanlist = g_slist_append (chanlist, chan);
|
|
|
|
|
|
|
|
return chanlist;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
servlist_favchan_add (ircnet *net, char *channel)
|
|
|
|
{
|
|
|
|
int pos;
|
|
|
|
char *name;
|
|
|
|
char *key;
|
|
|
|
|
2013-05-11 23:44:32 -04:00
|
|
|
if (strchr (channel, ',') != NULL)
|
|
|
|
{
|
2013-05-12 10:38:31 -04:00
|
|
|
pos = (int) (strchr (channel, ',') - channel);
|
2013-05-15 05:43:38 -04:00
|
|
|
name = g_strndup (channel, pos);
|
|
|
|
key = g_strdup (channel + pos + 1);
|
2013-05-11 23:44:32 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-15 05:43:38 -04:00
|
|
|
name = g_strdup (channel);
|
|
|
|
key = NULL;
|
2013-05-11 23:44:32 -04:00
|
|
|
}
|
|
|
|
|
2013-05-15 05:43:38 -04:00
|
|
|
net->favchanlist = servlist_favchan_listadd (net->favchanlist, name, key);
|
2013-05-11 23:44:32 -04:00
|
|
|
|
2013-05-15 05:43:38 -04:00
|
|
|
g_free (name);
|
|
|
|
g_free (key);
|
2013-05-11 23:44:32 -04:00
|
|
|
}
|
|
|
|
|
2011-02-23 22:14:30 -05:00
|
|
|
void
|
|
|
|
servlist_server_remove (ircnet *net, ircserver *serv)
|
|
|
|
{
|
2014-12-28 06:37:25 -05:00
|
|
|
g_free (serv->hostname);
|
|
|
|
g_free (serv);
|
2011-02-23 22:14:30 -05:00
|
|
|
net->servlist = g_slist_remove (net->servlist, serv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
servlist_server_remove_all (ircnet *net)
|
|
|
|
{
|
|
|
|
ircserver *serv;
|
|
|
|
|
|
|
|
while (net->servlist)
|
|
|
|
{
|
|
|
|
serv = net->servlist->data;
|
|
|
|
servlist_server_remove (net, serv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-14 10:40:32 -04:00
|
|
|
void
|
|
|
|
servlist_command_free (commandentry *entry)
|
|
|
|
{
|
|
|
|
g_free (entry->command);
|
|
|
|
g_free (entry);
|
|
|
|
}
|
|
|
|
|
2013-05-11 14:06:22 -04:00
|
|
|
void
|
|
|
|
servlist_command_remove (ircnet *net, commandentry *entry)
|
|
|
|
{
|
2013-05-14 10:40:32 -04:00
|
|
|
servlist_command_free (entry);
|
2013-05-11 14:06:22 -04:00
|
|
|
net->commandlist = g_slist_remove (net->commandlist, entry);
|
|
|
|
}
|
|
|
|
|
2013-05-11 23:44:32 -04:00
|
|
|
void
|
2013-05-14 10:40:32 -04:00
|
|
|
servlist_favchan_free (favchannel *channel)
|
2013-05-11 23:44:32 -04:00
|
|
|
{
|
|
|
|
g_free (channel->name);
|
|
|
|
g_free (channel->key);
|
|
|
|
g_free (channel);
|
2013-05-14 10:40:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
servlist_favchan_remove (ircnet *net, favchannel *channel)
|
|
|
|
{
|
|
|
|
servlist_favchan_free (channel);
|
2013-05-11 23:44:32 -04:00
|
|
|
net->favchanlist = g_slist_remove (net->favchanlist, channel);
|
|
|
|
}
|
|
|
|
|
|