コード例 #1
0
ファイル: servlist.c プロジェクト: Kyuuketsuki/xchat-aqua
static void
servlist_load_defaults (void)
{
	int i = 0, j = 0;
	ircnet *net = NULL;

	while (1)
	{
		if (def[i].network)
		{
			net = servlist_net_add (def[i].network, def[i].host, FALSE);
			net->encoding = strdup ("IRC (Latin/Unicode Hybrid)");
			if (def[i].channel)
				net->autojoin = strdup (def[i].channel);
			if (def[i].charset)
			{
				free (net->encoding);
				net->encoding = strdup (def[i].charset);
			}
			if (g_str_hash (def[i].network) == 0x8e1b96f7)
				prefs.slist_select = j;
			j++;
		} else
		{
			servlist_server_add (net, def[i].host);
			if (!def[i+1].host && !def[i+1].network)
				break;
		}
		i++;
	}
}
コード例 #2
0
ファイル: servlist.c プロジェクト: PChat/PChat
static void
servlist_load_defaults (void)
{
	int i = 0, j = 0;
	ircnet *net = NULL;

	while (1)
	{
		if (def[i].network)
		{
			net = servlist_net_add (def[i].network, def[i].host, FALSE);
			net->encoding = strdup (IRC_DEFAULT_CHARSET);
			if (def[i].channel)
				net->autojoin = strdup (def[i].channel);
			if (def[i].charset)
			{
				free (net->encoding);
				net->encoding = strdup (def[i].charset);
			}
			/* 0x8e1b96f7 = ChatJunkies, 0xa82686ae = FreeNode */
			if (g_str_hash (def[i].network) == 0xa82686ae)
				prefs.slist_select = j;
			j++;
		} else
		{
			servlist_server_add (net, def[i].host);
			if (!def[i+1].host && !def[i+1].network)
				break;
		}
		i++;
	}
}
コード例 #3
0
ファイル: servlist.c プロジェクト: xchat-gnome/xchat-gnome
static void servlist_load_defaults(void)
{
        int i = 0, j = 0;
        ircnet *net = NULL;

        while (1) {
                if (def[i].network) {
                        net = servlist_net_add(def[i].network, def[i].host, FALSE);
#ifdef WIN32
                        /* Windows gets UTF-8 for new users. Unix gets "System Default",
                                which is often UTF-8 anyway! */
                        net->encoding = strdup("UTF-8");
#endif
                        if (def[i].channel)
                                net->autojoin = strdup(def[i].channel);
                        if (def[i].charset) {
#ifdef WIN32
                                free(net->encoding);
#endif
                                net->encoding = strdup(def[i].charset);
                        }
                        if (g_str_hash(def[i].network) == 0x8e1b96f7)
                                prefs.slist_select = j;
                        j++;
                } else {
                        servlist_server_add(net, def[i].host);
                        if (!def[i + 1].host && !def[i + 1].network)
                                break;
                }
                i++;
        }
}
コード例 #4
0
ファイル: servlistgui.c プロジェクト: TingPing/conspire
static void
servlist_networks_populate (GtkWidget *treeview, GSList *netlist)
{
	GtkListStore *store;
	GtkTreeIter iter;
	int i;
	ircnet *net;

	if (!netlist)
	{
		net = servlist_net_add (_("New Network"), "", FALSE);
		servlist_server_add (net, "newserver/6667");
		netlist = network_list;
	}
	store = (GtkListStore *)gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
	gtk_list_store_clear (store);

	i = 0;
	while (netlist)
	{
		net = netlist->data;
		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter, 0, net->name, 1, 1, -1);
		if (i == prefs.slist_select)
		{
			/* select this network */
			servlist_select_and_show (GTK_TREE_VIEW (treeview), &iter, store);
			selected_net = net;
		}
		i++;
		netlist = netlist->next;
	}
}
コード例 #5
0
ファイル: servlist.c プロジェクト: HextorIRC/hextor
static void
servlist_load_defaults (void)
{
    int i = 0, j = 0;
    ircnet *net = NULL;
    guint def_hash = g_str_hash ("freenode");

    while (1)
    {
        if (def[i].network)
        {
            net = servlist_net_add (def[i].network, def[i].host, FALSE);
            if (def[i].channel)
            {
                servlist_favchan_add (net, def[i].channel);
            }
            if (def[i].charset)
            {
                net->encoding = g_strdup (def[i].charset);
            }
            else
            {
                net->encoding = g_strdup (IRC_DEFAULT_CHARSET);
            }
            if (def[i].loginmode)
            {
                net->logintype = def[i].loginmode;
            }
            if (def[i].connectcmd)
            {
                servlist_command_add (net, def[i].connectcmd);
            }
            if (def[i].ssl)
            {
                net->flags |= FLAG_USE_SSL;
            }

            if (g_str_hash (def[i].network) == def_hash)
            {
                prefs.hex_gui_slist_select = j;
            }

            j++;
        }
        else
        {
            servlist_server_add (net, def[i].host);
            if (!def[i+1].host && !def[i+1].network)
            {
                break;
            }
        }
        i++;
    }
}
コード例 #6
0
ファイル: servlist.c プロジェクト: GvinnBleid/xchat
static void
servlist_load_defaults (void)
{
	int i = 0, j = 0;
	ircnet *net = NULL;

	/* Agregado por Tuquito */
	net = servlist_net_add ("Tuquito Server", NULL, FALSE);
	servlist_server_add (net, "irc.debian.org");
	net->autojoin = strdup (_("#tuquito"));
	net->flags |= FLAG_AUTO_CONNECT;

	while (1)
	{
		if (def[i].network)
		{
			net = servlist_net_add (def[i].network, def[i].host, FALSE);
			net->encoding = strdup ("IRC (Latin/Unicode Hybrid)");
			if (def[i].channel)
				net->autojoin = strdup (def[i].channel);
			if (def[i].charset)
			{
				free (net->encoding);
				net->encoding = strdup (def[i].charset);
			}
			if (g_str_hash (def[i].network) == 0x8e1b96f7)
				prefs.slist_select = j;
			j++;
		} else
		{
			servlist_server_add (net, def[i].host);
			if (!def[i+1].host && !def[i+1].network)
				break;
		}
		i++;
	}
}
コード例 #7
0
ファイル: servlistgui.c プロジェクト: TingPing/conspire
static void
servlist_addnet_cb (GtkWidget *item, GtkTreeView *treeview)
{
	GtkTreeIter iter;
	GtkListStore *store;
	ircnet *net;

	store = (GtkListStore *)gtk_tree_view_get_model (treeview);
	net = servlist_net_add (_("New Network"), "", TRUE);
	servlist_server_add (net, "newserver/6667");

	gtk_list_store_prepend (store, &iter);
	gtk_list_store_set (store, &iter, 0, net->name, 1, 1, -1);

	/* select this network */
	servlist_select_and_show (GTK_TREE_VIEW (networks_tree), &iter, store);
	servlist_start_editing (GTK_TREE_VIEW (networks_tree));

	servlist_network_row_cb (gtk_tree_view_get_selection (GTK_TREE_VIEW (networks_tree)), NULL);
}
コード例 #8
0
ファイル: servlist.c プロジェクト: 94m3k1n9/hexchat
static void
servlist_load_defaults (void)
{
	int i = 0, j = 0;
	ircnet *net = NULL;
	guint def_hash = g_str_hash ("freenode");

	while (1)
	{
		if (def[i].network)
		{
			net = servlist_net_add (def[i].network, def[i].host, FALSE);
			net->encoding = strdup (IRC_DEFAULT_CHARSET);
			if (def[i].channel)
			{
				net->autojoin = strdup (def[i].channel);
			}
			if (def[i].charset)
			{
				free (net->encoding);
				net->encoding = strdup (def[i].charset);
			}
			if (g_str_hash (def[i].network) == def_hash)
			{
				prefs.hex_gui_slist_select = j;
			}
			j++;
		}
		else
		{
			servlist_server_add (net, def[i].host);
			if (!def[i+1].host && !def[i+1].network)
			{
				break;
			}
		}
		i++;
	}
}
コード例 #9
0
ファイル: servlist.c プロジェクト: HextorIRC/hextor
static int
servlist_load (void)
{
    FILE *fp;
    char buf[2048];
    int len;
    ircnet *net = NULL;

    /* simple migration we will keep for a short while */
    char *oldfile = g_build_filename (get_xdir (), "servlist_.conf", NULL);
    char *newfile = g_build_filename (get_xdir (), "servlist.conf", NULL);

    if (g_file_test (oldfile, G_FILE_TEST_EXISTS) && !g_file_test (newfile, G_FILE_TEST_EXISTS))
    {
        g_rename (oldfile, newfile);
    }

    g_free (oldfile);
    g_free (newfile);

    fp = hextor_fopen_file ("servlist.conf", "r", 0);
    if (!fp)
        return FALSE;

    while (fgets (buf, sizeof (buf) - 2, fp))
    {
        len = strlen (buf);
        buf[len] = 0;
        buf[len-1] = 0; /* remove the trailing \n */
        if (net)
        {
            switch (buf[0])
            {
            case 'I':
                net->nick = g_strdup (buf + 2);
                break;
            case 'i':
                net->nick2 = g_strdup (buf + 2);
                break;
            case 'U':
                net->user = g_strdup (buf + 2);
                break;
            case 'R':
                net->real = g_strdup (buf + 2);
                break;
            case 'P':
                net->pass = g_strdup (buf + 2);
                break;
            case 'L':
                net->logintype = atoi (buf + 2);
                break;
            case 'E':
                net->encoding = servlist_check_encoding (buf + 2) ? g_strdup (buf + 2) : g_strdup ("UTF-8");
                break;
            case 'F':
                net->flags = atoi (buf + 2);
                break;
            case 'S':       /* new server/hostname for this network */
                servlist_server_add (net, buf + 2);
                break;
            case 'C':
                servlist_command_add (net, buf + 2);
                break;
            case 'J':
                servlist_favchan_add (net, buf + 2);
                break;
            case 'D':
                net->selected = atoi (buf + 2);
                break;
                /* FIXME Migration code. In 2.9.5 the order was:
                 *
                 * P=serverpass, A=saslpass, B=nickservpass
                 *
                 * So if server password was unset, we can safely use SASL
                 * password for our new universal password, or if that's also
                 * unset, use NickServ password.
                 *
                 * Should be removed at some point.
                 */
            case 'A':
                if (!net->pass)
                {
                    net->pass = g_strdup (buf + 2);
                    if (!net->logintype)
                    {
                        net->logintype = LOGIN_SASL;
                    }
                }
            case 'B':
                if (!net->pass)
                {
                    net->pass = g_strdup (buf + 2);
                    if (!net->logintype)
                    {
                        net->logintype = LOGIN_NICKSERV;
                    }
                }
            }
        }
        if (buf[0] == 'N')
            net = servlist_net_add (buf + 2, /* comment */ NULL, FALSE);
    }
    fclose (fp);

    return TRUE;
}
コード例 #10
0
ファイル: servlist.c プロジェクト: PChat/PChat
static int
servlist_load (void)
{
	FILE *fp;
	char buf[2048];
	int len;
	char *tmp;
	ircnet *net = NULL;

	fp = xchat_fopen_file ("servlist_.conf", "r", 0);
	if (!fp)
		return FALSE;

	while (fgets (buf, sizeof (buf) - 2, fp))
	{
		len = strlen (buf);
		buf[len] = 0;
		buf[len-1] = 0;	/* remove the trailing \n */
		if (net)
		{
			switch (buf[0])
			{
			case 'I':
				net->nick = strdup (buf + 2);
				break;
			case 'i':
				net->nick2 = strdup (buf + 2);
				break;
			case 'U':
				net->user = strdup (buf + 2);
				break;
			case 'R':
				net->real = strdup (buf + 2);
				break;
			case 'P':
				net->pass = strdup (buf + 2);
				break;
			case 'J':
				net->autojoin = strdup (buf + 2);
				break;
			case 'C':
				if (net->command)
				{
					/* concat extra commands with a \n separator */
					tmp = net->command;
					net->command = malloc (strlen (tmp) + strlen (buf + 2) + 2);
					strcpy (net->command, tmp);
					strcat (net->command, "\n");
					strcat (net->command, buf + 2);
					free (tmp);
				} else
					net->command = strdup (buf + 2);
				break;
			case 'F':
				net->flags = atoi (buf + 2);
				break;
			case 'D':
				net->selected = atoi (buf + 2);
				break;
			case 'E':
				net->encoding = strdup (buf + 2);
				break;
			case 'S':	/* new server/hostname for this network */
				servlist_server_add (net, buf + 2);
				break;
			case 'B':
				net->nickserv = strdup (buf + 2);
				break;
			}
		}
		if (buf[0] == 'N')
			net = servlist_net_add (buf + 2, /* comment */ NULL, FALSE);
	}
	fclose (fp);

	return TRUE;
}
コード例 #11
0
ファイル: servlist.cpp プロジェクト: leeter/hexchat
static bool servlist_load (void)
{
	namespace bfs = boost::filesystem;
	namespace bs = boost::system;

	/* simple migration we will keep for a short while */
	auto oldfile = io::fs::make_config_path("servlist_.conf");
	auto newfile = io::fs::make_config_path("servlist.conf");
	
	bs::error_code ec;
	if (bfs::exists(oldfile, ec) && !bfs::exists(newfile, ec))
	{
		bfs::rename(oldfile, newfile, ec);
	}

	bfs::ifstream infile(io::fs::make_config_path("servlist.conf"), std::ios::in);
	if (!infile)
		return false;

	ircnet *net = nullptr;

	for(std::string buf; std::getline(infile, buf);)
	{
		if (net)
		{
			switch (buf[0])
			{
			case 'I':
				net->nick = buf.substr(2);
				break;
			case 'i':
				net->nick2 = buf.substr(2);
				break;
			case 'U':
				net->user = strdup (buf.c_str() + 2);
				break;
			case 'R':
				net->real = strdup (buf.c_str() + 2);
				break;
			case 'P':
				net->pass = strdup (buf.c_str() + 2);
				break;
			case 'L':
				net->logintype = std::atoi (buf.c_str() + 2);
				break;
			case 'E':
				net->encoding = strdup (buf.c_str() + 2);
				break;
			case 'F':
				net->flags = std::atoi (buf.c_str() + 2);
				break;
			case 'S':	/* new server/hostname for this network */
				servlist_server_add (net, buf.c_str() + 2);
				break;
			case 'C':
				servlist_command_add (net, buf.c_str() + 2);
				break;
			case 'J':
				servlist_favchan_add (net, buf.c_str() + 2);
				break;
			case 'D':
				net->selected = std::atoi (buf.c_str() + 2);
				break;
			/* FIXME Migration code. In 2.9.5 the order was:
			 *
			 * P=serverpass, A=saslpass, B=nickservpass
			 *
			 * So if server password was unset, we can safely use SASL
			 * password for our new universal password, or if that's also
			 * unset, use NickServ password.
			 *
			 * Should be removed at some point.
			 */
			case 'A':
				if (!net->pass)
				{
					net->pass = strdup (buf.c_str() + 2);
					if (!net->logintype)
					{
						net->logintype = LOGIN_SASL;
					}
				}
			case 'B':
				if (!net->pass)
				{
					net->pass = strdup (buf.c_str() + 2);
					if (!net->logintype)
					{
						net->logintype = LOGIN_NICKSERV;
					}
				}
			}
		}
		if (!buf.empty() && buf[0] == 'N')
			net = servlist_net_add (buf.c_str() + 2, /* comment */ nullptr, false);
	}

	return true;
}