示例#1
0
/*Doesn't do anything yet*/
void gaym_try_cached_password(GaimAccount * account,
                              void (*callback) (GaimAccount * account))
{

    const char *pw;
    pw = gaim_account_get_string(account, "chat_key", NULL);
    if (pw == NULL) {
        gaym_get_chat_key_from_weblogin(account, callback);
        return;
    }
    // All in one shot:
    // 1. Login to the irc server <--- blocks serv_login
    // 2. grab the applet <--- blocks serv_login
    // 3. spamlist update <--- does not block serv_login
    // 4. get config.txt <--- does not block serv_login
    // 
    // Note: if the chat key happens to be invalid, 2 and 4 will fail.

    // 1
    // callback(gaym->account);

    // 2

    // 3


    // 4

}
示例#2
0
void gaym_try_cached_password(GaimAccount * account,
                            void (*callback) (GaimAccount * account))
{

    const char* pw;
    pw=gaim_account_get_string(account, "password", NULL);
    if (pw==NULL)
        gaym_get_hash_from_weblogin(account, callback);
    

}
示例#3
0
文件: irc.c 项目: VoxOx/VoxOx
static gboolean do_login(GaimConnection *gc) {
	char *buf;
	char hostname[256];
	const char *username, *realname;
	struct irc_conn *irc = gc->proto_data;
	const char *pass = gaim_connection_get_password(gc);

	if (pass && *pass) {
		buf = irc_format(irc, "vv", "PASS", pass);
		if (irc_send(irc, buf) < 0) {
/*			gaim_connection_error(gc, "Error sending password"); */
			g_free(buf);
			return FALSE;
		}
		g_free(buf);
	}

	gethostname(hostname, sizeof(hostname));
	hostname[sizeof(hostname) - 1] = '\0';
	username = gaim_account_get_string(irc->account, "username", "");
	realname = gaim_account_get_string(irc->account, "realname", "");
	buf = irc_format(irc, "vvvv:", "USER", strlen(username) ? username : g_get_user_name(), hostname, irc->server,
			      strlen(realname) ? realname : IRC_DEFAULT_ALIAS);
	if (irc_send(irc, buf) < 0) {
/*		gaim_connection_error(gc, "Error registering with server");*/
		g_free(buf);
		return FALSE;
	}
	g_free(buf);
	buf = irc_format(irc, "vn", "NICK", gaim_connection_get_display_name(gc));
	if (irc_send(irc, buf) < 0) {
/*		gaim_connection_error(gc, "Error sending nickname");*/
		g_free(buf);
		return FALSE;
	}
	g_free(buf);

	irc->recv_time = time(NULL);

	return TRUE;
}
示例#4
0
static void gaym_login_cb(gpointer data, gint source,
                          GaimInputCondition cond)
{
    GaimConnection *gc = data;
    struct gaym_conn *gaym = gc->proto_data;
    char hostname[256];
    char *buf;
    const char *username;
    const char *user_bioline = NULL;
    char *bioline;
    char *login_name;

    if (GAIM_CONNECTION_IS_VALID(gc)) {


        GList *connections = gaim_connections_get_all();

        if (source < 0) {
            gaim_connection_error(gc, _("Couldn't connect to host"));
            return;
        }

        if (!g_list_find(connections, gc)) {
            close(source);
            return;
        }

        gaym->fd = source;
        gaim_debug_misc("gaym", "In login_cb with chat_key=%s\n",
                        gaym->chat_key);
        if (gaym->chat_key) {

            buf = gaym_format(gaym, "vv", "PASS", gaym->chat_key);
            if (gaym_send(gaym, buf) < 0) {
                gaim_connection_error(gc, "Error sending password");
                return;
            }
            g_free(buf);
        } else {
            gaim_connection_error(gc,
                                  _
                                  ("Password wasn't recorded. Report bug."));
            return;
        }
        gethostname(hostname, sizeof(hostname));
        hostname[sizeof(hostname) - 1] = '\0';
        username = gaim_account_get_string(gaym->account, "username", "");
        user_bioline =
            g_strdup(gaim_account_get_string
                     (gaym->account, "bioline", ""));
        gaim_debug_info("gaym", "USER BIOLINE=%x\n", user_bioline);
        gaim_account_set_user_info(gc->account, user_bioline);
        gaim_debug_misc("gaym",
                        "In login_cb, user_bioline: %x, gc->account=%x\n",
                        user_bioline, gc->account);

        login_name =
            gaym_nick_to_gcom_strdup(gaim_connection_get_display_name(gc));
        bioline = g_strdup_printf("%s#%s\xC2\xA0 \xC2\xA0\001%s",
                                  gaym->thumbnail,
                                  user_bioline ? user_bioline : "",
                                  gaym->server_stats ? gaym->
                                  server_stats : "");

        buf = gaym_format(gaym, "vn", "NICK", login_name);
        gaim_debug_misc("gaym", "Command: %s\n", buf);

        if (gaym_send(gaym, buf) < 0) {
            gaim_connection_error(gc, "Error sending nickname");
            return;
        }
        g_free(buf);
        buf =
            gaym_format(gaym, "vvvv:", "USER", login_name, hostname,
                        gaym->server, bioline);

        gaim_debug_misc("gaym", "Command: %s\n", buf);
        if (gaym_send(gaym, buf) < 0) {
            gaim_connection_error(gc, "Error registering with server");
            return;
        }
        g_free(login_name);
        g_free(buf);

        const char *server = gaim_account_get_string(gc->account, "server",
                                                     IRC_DEFAULT_SERVER);
        char *url =
            g_strdup_printf
            ("http://%s/messenger/config.txt?%s", server, gaym->chat_key);

        char *user_agent = "Mozilla/4.0";

        get_spamlist_from_web();
        gaim_url_fetch(url, FALSE, user_agent, FALSE,
                       gaym_get_configtxt_cb, gaym);

        g_free(url);
        gc->inpa =
            gaim_input_add(gaym->fd, GAIM_INPUT_READ, gaym_input_cb, gc);


    }
}
示例#5
0
static void gaym_login(GaimAccount * account)
{
    GaimConnection *gc;
    struct gaym_conn *gaym;
    char *buf;
    const char *username = gaim_account_get_username(account);

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

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

    gc->proto_data = gaym = g_new0(struct gaym_conn, 1);
    gaym->account = account;


    /**
     * gaim_connection_set_display_name(gc, userparts[0]);
     */
    gaim_connection_set_display_name(gc, username);
    gaym->server =
        g_strdup(gaim_account_get_string
                 (account, "server", "www.gay.com"));
    /**
     * gaym->server = "www.gay.com";
     */
    gaym->buddies =
        g_hash_table_new_full((GHashFunc) gaym_nick_hash,
                              (GEqualFunc) gaym_nick_equal, NULL,
                              (GDestroyNotify) gaym_buddy_free);

    gaym->channel_members =
        g_hash_table_new_full((GHashFunc) gaym_nick_hash,
                              (GEqualFunc) gaym_nick_equal, NULL,
                              (GDestroyNotify) gaym_channel_member_free);

    gaym->cmds = g_hash_table_new(g_str_hash, g_str_equal);
    gaym_cmd_table_build(gaym);
    gaym->msgs = g_hash_table_new(g_str_hash, g_str_equal);
    gaym_msg_table_build(gaym);
    gaym->roomlist_filter = NULL;

    gaym->hammers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)hammer_cb_data_destroy);
    /**
     * The last parameter needs to be NULL here, since the same
     * field is added for both the key and the value (and if we
     * free it twice, thats bad and causes crashing!).
     */
    gaym->info_window_needed =
        g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);

    gaym->entry_order =
        g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);

    /**
     * This is similar to gaym->info_window_needed, except this is
     * for thumbails inside the IM conversation window if the
     * person is not already on the buddy list
     */

    buf = g_strdup_printf(_("Signon: %s"), username);
    gaim_connection_update_progress(gc, buf, 1, 6);
    g_free(buf);


    /**
     * Making a change to try cached password first.
     * gaym_try_cached_password(account, gaym_login_with_chat_key);
     */
    gaym_get_chat_key_from_weblogin(account, gaym_login_with_chat_key);
}