Exemplo n.º 1
0
Arquivo: irc.c Projeto: VoxOx/VoxOx
static void irc_login(GaimAccount *account)
{
	GaimConnection *gc;
	struct irc_conn *irc;
	char **userparts;
	const char *username = gaim_account_get_username(account);

	gc = gaim_account_get_connection(account);
	gc->flags |= GAIM_CONNECTION_NO_NEWLINES;

	if (strpbrk(username, " \t\v\r\n") != NULL) {
		gaim_connection_error(gc, _("IRC nicks may not contain whitespace"));
		return;
	}

	gc->proto_data = irc = g_new0(struct irc_conn, 1);
	irc->fd = -1;
	irc->account = account;
	irc->outbuf = gaim_circ_buffer_new(512);

	userparts = g_strsplit(username, "@", 2);
	gaim_connection_set_display_name(gc, userparts[0]);
	irc->server = g_strdup(userparts[1]);
	g_strfreev(userparts);

	irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal,
					     NULL, (GDestroyNotify)irc_buddy_free);
	irc->cmds = g_hash_table_new(g_str_hash, g_str_equal);
	irc_cmd_table_build(irc);
	irc->msgs = g_hash_table_new(g_str_hash, g_str_equal);
	irc_msg_table_build(irc);

	gaim_connection_update_progress(gc, _("Connecting"), 1, 2);

	if (gaim_account_get_bool(account, "ssl", FALSE)) {
		if (gaim_ssl_is_supported()) {
			irc->gsc = gaim_ssl_connect(account, irc->server,
					gaim_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT),
					irc_login_cb_ssl, irc_ssl_connect_failure, gc);
		} else {
			gaim_connection_error(gc, _("SSL support unavailable"));
			return;
		}
	}

	if (!irc->gsc) {

		if (gaim_proxy_connect(gc, account, irc->server,
				 gaim_account_get_int(account, "port", IRC_DEFAULT_PORT),
				 irc_login_cb, gc) == NULL)
		{
			gaim_connection_error(gc, _("Couldn't create socket"));
			return;
		}
	}
}
Exemplo n.º 2
0
static void gaym_login_with_chat_key(GaimAccount * account)
{
    GaimConnection *gc;
    struct gaym_conn *gaym;
    char *buf;
    const char *username = gaim_account_get_username(account);
    int err;

    gc = gaim_account_get_connection(account);
    gaym = gc->proto_data;

    buf = g_strdup_printf(_("Signon: %s"), username);
    gaim_connection_update_progress(gc, buf, 5, 6);
    g_free(buf);
    gaim_debug_misc("gaym", "Trying login to %s\n", gaym->server);
    err = gaim_proxy_connect(account, gaym->server,
                             gaim_account_get_int(account, "port",
                                                  IRC_DEFAULT_PORT),
                             gaym_login_cb, gc);
    if (err || !account->gc) {
        gaim_connection_error(gc, _("Couldn't create socket"));
        gaim_debug_misc("gaym", "err: %d, account->gc: %x\n", err,
                        account->gc);
        return;
    }

}
Exemplo n.º 3
0
Arquivo: status.c Projeto: VoxOx/VoxOx
gint
gaim_presence_compare(const GaimPresence *presence1,
		const GaimPresence *presence2)
{
	gboolean idle1, idle2;
	time_t idle_time_1, idle_time_2;
	int score1 = 0, score2 = 0;
	const GList *l;

	if (presence1 == presence2)
		return 0;
	else if (presence1 == NULL)
		return 1;
	else if (presence2 == NULL)
		return -1;

	/* Compute the score of the first set of statuses. */
	for (l = gaim_presence_get_statuses(presence1); l != NULL; l = l->next)
	{
		GaimStatus *status = (GaimStatus *)l->data;
		GaimStatusType *type = gaim_status_get_type(status);

		if (gaim_status_is_active(status))
			score1 += primitive_scores[gaim_status_type_get_primitive(type)];
	}
	score1 += gaim_account_get_int(gaim_presence_get_account(presence1), "score", 0);

	/* Compute the score of the second set of statuses. */
	for (l = gaim_presence_get_statuses(presence2); l != NULL; l = l->next)
	{
		GaimStatus *status = (GaimStatus *)l->data;
		GaimStatusType *type = gaim_status_get_type(status);

		if (gaim_status_is_active(status))
			score2 += primitive_scores[gaim_status_type_get_primitive(type)];
	}
	score2 += gaim_account_get_int(gaim_presence_get_account(presence2), "score", 0);

	idle1 = gaim_presence_is_idle(presence1);
	idle2 = gaim_presence_is_idle(presence2);

	if (idle1)
		score1 += primitive_scores[SCORE_IDLE];

	if (idle2)
		score2 += primitive_scores[SCORE_IDLE];

	idle_time_1 = time(NULL) - gaim_presence_get_idle_time(presence1);
	idle_time_2 = time(NULL) - gaim_presence_get_idle_time(presence2);

	if (idle_time_1 > idle_time_2)
		score1 += primitive_scores[SCORE_IDLE_TIME];
	else if (idle_time_1 < idle_time_2)
		score2 += primitive_scores[SCORE_IDLE_TIME];

	if (score1 < score2)
		return 1;
	else if (score1 > score2)
		return -1;

	return 0;
}