Exemplo n.º 1
0
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;

    /* in case a protocol switch is added to the servlist gui */
    server_fill_her_up (sess->server);

    if (join)
    {
        sess->willjoinchannel[0] = 0;

        if (net->favchanlist)
        {
            if (serv->favlist)
            {
                g_slist_free_full (serv->favlist, (GDestroyNotify) servlist_favchan_free);
            }
            serv->favlist = g_slist_copy_deep (net->favchanlist, (GCopyFunc) servlist_favchan_copy, NULL);
        }
    }

    if (net->logintype)
    {
        serv->loginmethod = net->logintype;
    }
    else
    {
        serv->loginmethod = LOGIN_DEFAULT_REAL;
    }

    serv->password[0] = 0;

    if (net->pass)
    {
        safe_strcpy (serv->password, net->pass, sizeof (serv->password));
    }

    if (net->flags & FLAG_USE_GLOBAL)
    {
        strcpy (serv->nick, prefs.hex_irc_nick1);
    }
    else
    {
        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);
}
Exemplo n.º 2
0
void
inbound_005 (server * serv, char *word[])
{
	int w;
	char *pre;

	w = 4;							  /* start at the 4th word */
	while (w < PDIWORDS && *word[w])
	{
		if (strncmp (word[w], "MODES=", 6) == 0)
		{
			serv->modes_per_line = atoi (word[w] + 6);
		} else if (strncmp (word[w], "CHANTYPES=", 10) == 0)
		{
			free (serv->chantypes);
			serv->chantypes = strdup (word[w] + 10);
		} else if (strncmp (word[w], "CHANMODES=", 10) == 0)
		{
			free (serv->chanmodes);
			serv->chanmodes = strdup (word[w] + 10);
		} else if (strncmp (word[w], "PREFIX=", 7) == 0)
		{
			pre = strchr (word[w] + 7, ')');
			if (pre)
			{
				pre[0] = 0;			  /* NULL out the ')' */
				free (serv->nick_prefixes);
				free (serv->nick_modes);
				serv->nick_prefixes = strdup (pre + 1);
				serv->nick_modes = strdup (word[w] + 8);
			} else
			{
				/* bad! some ircds don't give us the modes. */
				/* in this case, we use it only to strip /NAMES */
				serv->bad_prefix = TRUE;
				if (serv->bad_nick_prefixes)
					free (serv->bad_nick_prefixes);
				serv->bad_nick_prefixes = strdup (word[w] + 7);
			}
		} else if (strncmp (word[w], "WATCH=", 6) == 0)
		{
			serv->supports_watch = TRUE;
		} else if (strncmp (word[w], "MONITOR=", 8) == 0)
		{
			serv->supports_monitor = TRUE;
		} else if (strncmp (word[w], "NETWORK=", 8) == 0)
		{
/*			if (serv->networkname)
				free (serv->networkname);
			serv->networkname = strdup (word[w] + 8);*/

			if (serv->server_session->type == SESS_SERVER)
			{
				safe_strcpy (serv->server_session->channel, word[w] + 8, CHANLEN);
				fe_set_channel (serv->server_session);
			}

			/* use /NICKSERV */
			if (g_ascii_strcasecmp (word[w] + 8, "UniBG") == 0)
				serv->nickservtype = 3;
			else if (g_ascii_strcasecmp (word[w] + 8, "QuakeNet") == 0)
				serv->nickservtype = 4;

		} else if (strncmp (word[w], "CASEMAPPING=", 12) == 0)
		{
			if (strcmp (word[w] + 12, "ascii") == 0)	/* bahamut */
				serv->p_cmp = (void *)g_ascii_strcasecmp;
		} else if (strncmp (word[w], "CHARSET=", 8) == 0)
		{
			if (g_ascii_strcasecmp (word[w] + 8, "UTF-8") == 0)
			{
				server_set_encoding (serv, "UTF-8");
			}
		} else if (strcmp (word[w], "NAMESX") == 0)
		{
									/* 12345678901234567 */
			tcp_send_len (serv, "PROTOCTL NAMESX\r\n", 17);
		} else if (strcmp (word[w], "WHOX") == 0)
		{
			serv->have_whox = TRUE;
		} else if (strcmp (word[w], "EXCEPTS") == 0)
		{
#ifndef WIN32
			serv->have_except = TRUE;
#endif
		} else if (strcmp (word[w], "INVEX") == 0)
		{
			/* supports mode letter +I, default channel invite */
			serv->have_invite = TRUE;
		} else if (strncmp (word[w], "ELIST=", 6) == 0)
		{
			/* supports LIST >< min/max user counts? */
			if (strchr (word[w] + 6, 'U') || strchr (word[w] + 6, 'u'))
				serv->use_listargs = TRUE;
		}

		w++;
	}
}