예제 #1
0
static void
gaym_weblogin_step2(gpointer data, const char *text, size_t len)
{

    struct gaym_conn *gaym = (struct gaym_conn *) data;
    gaim_debug_misc("gaym", "Step 2: gaym->sessoin: %x\n", gaym->session);
    if (gaym->session
        && GAIM_CONNECTION_IS_VALID(gaym->session->account->gc)) {
        // The second step is to do the actual login.
        // We connect to misc/dologin.html, using cookies set from step 1
        // And add a few more cookie values.
        char url[1024];
        char *buf = g_strdup_printf(_("Signon: %s"),
                                    gaym->session->account->username);
        gaim_connection_update_progress(gaym->session->account->gc, buf, 3,
                                        6);

        snprintf(url, 1024,
                 "http://www.gay.com/misc/dologin.html?__login_haveForm=1&__login_save=1&__login_member=%s&redir=%%2Findex.html&__login_basepage=%%2Fmisc%%2Fdologin.html&__login_password=%s",
                 gaym->session->username, gaym->session->password);

        gaym->session->hasFormData = TRUE;
        gaim_session_fetch(url, FALSE, NULL, FALSE, gaym_weblogin_step3,
                           gaym, gaym->session);
    } else {
        gaim_debug_misc("gaym", "Connection was cancelled before step2\n");
        gaim_debug_misc("gaym", "gaym->sessoin: %x\n", gaym->session);
        // g_free(gaym->session);
    }
}
예제 #2
0
static void
gaym_weblogin_step4(gpointer data, const char *text, size_t len)
{

    struct gaym_conn *gaym = (struct gaym_conn *) data;
    gaim_debug_misc("gaym", "Step 4: gaym->sessoin: %x\n", gaym->session);
    if (gaym->session
        && GAIM_CONNECTION_IS_VALID(gaym->session->account->gc)) {
        // The fourth step is to parse a rand=# value out of the message
        // text from
        // The previous step.
        // We then connect to messenger/applet.html
        char url[512];
        int nonce;
        char *buf = g_strdup_printf(_("Signon: %s"),
                                    (gaym->session->account->username));
        gaim_connection_update_progress(gaym->session->account->gc, buf, 5,
                                        6);
        sscanf(text, "?rand=%d", &nonce);
        snprintf(url, 512,
                 "http://www.gay.com/messenger/applet.html?rand=%d",
                 nonce);

        gaym->session->hasFormData = TRUE;
        gaim_session_fetch(url, FALSE, NULL, FALSE, gaym_weblogin_step5,
                           gaym, gaym->session);
    } else {
        gaim_debug_misc("gaym", "Connection was cancelled before step4\n");
        gaim_debug_misc("gaym", "gaym->sessoin: %x\n", gaym->session);
        // g_free(gaym->session);
    }
}
예제 #3
0
/*
static void
gaym_weblogin_step1(gpointer session) {

	if(GAIM_CONNECTION_IS_VALID(((GaimUrlSession*)session)->account->gc))
	{
	//The first step is to establish the initial sesion
	//We connect to index.html, and get a few cookie values. 
	char* url = "http://www.gay.com/index.html";
	char* buf = g_strdup_printf(_("Signon: %s"), ((GaimUrlSession*)session)->account->username);
	gaim_connection_update_progress(((GaimUrlSession*)session)->account->gc, buf, 2, 6);
	((GaimUrlSession*)session)->hasFormData=FALSE;
	gaim_session_fetch(url, FALSE, NULL, FALSE,gaym_weblogin_step2, session);
	}
	else
		g_free(session);
}
*/
void 
gaym_get_hash_from_weblogin(GaimAccount* account, void(*callback)(GaimAccount* account)) {
	
	struct gaym_conn* gaym=account->gc->proto_data;
	if(GAIM_CONNECTION_IS_VALID(account->gc))
	{
	
	GaimUrlSession* session=g_new0(GaimUrlSession, 1);
	session->session_cb = callback;
	session->cookies=NULL;
	session->account=account;
	session->username=g_strdup(account->username);
	session->password=g_strdup(account->password);
	if(gaym->session)
		g_free(gaym->session);
	
	gaym->session=session;
	
	if(GAIM_CONNECTION_IS_VALID(((GaimUrlSession*)session)->account->gc))
	{
	//The first step is to establish the initial sesion
	//We connect to index.html, and get a few cookie values. 
		char* url = "http://www.gay.com/index.html";
		char* buf = g_strdup_printf(_("Signon: %s"), ((GaimUrlSession*)session)->account->username);
		gaim_connection_update_progress(((GaimUrlSession*)session)->account->gc, buf, 2, 6);
		((GaimUrlSession*)session)->hasFormData=FALSE;
		gaim_session_fetch(url, FALSE, NULL, FALSE,gaym_weblogin_step2, gaym, gaym->session);
	}
	
	}
}
예제 #4
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;
    }

}
예제 #5
0
파일: irc.c 프로젝트: 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;
		}
	}
}
예제 #6
0
void
gaym_get_hash_from_weblogin(GaimAccount * account,
                            void (*callback) (GaimAccount * account))
{

    struct gaym_conn *gaym = account->gc->proto_data;
    if (GAIM_CONNECTION_IS_VALID(account->gc)) {

        // FIXME: By passing struct gaym_conn around through the 
        // callbacks, instead of a GaimAccount struct, we will
        // lose the information needed to free this session if 
        // conncetion is cancelled. This needs to be modified
        // to make sure that the GaimUrlSession *session memory
        // is not leaked!

        GaimUrlSession *session = g_new0(GaimUrlSession, 1);
        session->session_cb = callback;
        session->cookies = NULL;
        session->account = account;
        session->username = g_strdup(account->username);
        session->password = g_strdup(account->password);
        if (gaym->session)
            g_free(gaym->session);

        gaym->session = session;

        gaim_debug_misc("gaym", "Made gaym->session: %x\n", gaym->session);
        if (GAIM_CONNECTION_IS_VALID
            (((GaimUrlSession *) session)->account->gc)) {
            // The first step is to establish the initial sesion
            // We connect to index.html, and get a few cookie values.
            char *url = "http://www.gay.com/index.html";
            char *buf = g_strdup_printf(_("Signon: %s"),
                                        ((GaimUrlSession *) session)->
                                        account->username);
            gaim_connection_update_progress(((GaimUrlSession *) session)->
                                            account->gc, buf, 2, 6);
            ((GaimUrlSession *) session)->hasFormData = FALSE;
            gaim_session_fetch(url, FALSE, NULL, FALSE,
                               gaym_weblogin_step2, gaym, gaym->session);
        } else {
            gaim_debug_misc("gaym", "cancelled before step1\n");
            gaim_debug_misc("gaym", "gaym->sessoin: %x\n", gaym->session);
        }

    }
}
예제 #7
0
static void
gaym_weblogin_step3(gpointer data, const char* text, size_t len) {

	struct gaym_conn *gaym=(struct gaym_conn*)data;
	if(GAIM_CONNECTION_IS_VALID(gaym->account->gc))
	{
	//The third step is to get a nonce needed for getting the applet.
	//We connect to messenger/frameset.html, using previously set cookie values.
	//From the returned body, we will need to parse out the rand values.
	char* url = "http://www.gay.com/messenger/frameset.html";
	char* buf = g_strdup_printf(_("Signon: %s"), (gaym->session->account->username));
	gaim_connection_update_progress(gaym->session->account->gc, buf, 4, 6);
	gaym->session->hasFormData=FALSE;
	gaim_session_fetch(url, FALSE, NULL, FALSE,gaym_weblogin_step4, gaym, gaym->session);
	}
	else
		g_free(gaym->session);
}
예제 #8
0
static void
gaym_weblogin_step3(gpointer data, const char *text, size_t len)
{




    struct gaym_conn *gaym = (struct gaym_conn *) data;

    gaim_debug_misc("gaym", "Step 3: gaym->sessoin: %x\n", gaym->session);
    if (gaym && gaym->session
        && GAIM_CONNECTION_IS_VALID(gaym->session->account->gc)) {
        if (!strstr(gaym->session->cookies, "MEMBERX")) {
            g_free(gaym->session);
            gaim_connection_error((gaym->account->gc),
                                  _
                                  ("Problem during login. Are you sure your password is correct?"));
            return;
        }
        // The third step is to get a nonce needed for getting the applet.
        // We connect to messenger/frameset.html, using previously set
        // cookie values.
        // From the returned body, we will need to parse out the rand
        // values.
        char *url = "http://www.gay.com/messenger/frameset.html";
        char *buf = g_strdup_printf(_("Signon: %s"),
                                    (gaym->session->account->username));
        gaim_connection_update_progress(gaym->session->account->gc, buf, 4,
                                        6);
        gaym->session->hasFormData = FALSE;
        gaim_session_fetch(url, FALSE, NULL, FALSE, gaym_weblogin_step4,
                           gaym, gaym->session);
    } else {

        gaim_debug_misc("gaym", "Connection was cancelled before step3\n");
        gaim_debug_misc("gaym", "gaym->sessoin: %x\n", gaym->session);
        // g_free(gaym->session);

    }
}
예제 #9
0
static void
sippy_recv_cb(gpointer data, gint source, GaimInputCondition condition)
{
  GaimConnection *gc = data;
  int len;
  int command;
  static char buf[4096];
  static char bufFrom[4096];
  static char bufTo[4096];
  
  len = read( FD_GAG_TO_GAIM, &command, sizeof(command ) );
  if ( len == -1 )
  {
     int err = errno;
     gaim_debug(GAIM_DEBUG_INFO,"sippy","err=%d\n",err);  
     /* something really bad happened */
     resip_assert(0);
  }
  if ( len == 0 )
  {
     /* not ready */
     return;
  }
  resip_assert( len == sizeof(command) );
  
  switch ( command )
  {
     case SIMPLE_IM:
     {	
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got an IM messages from gag\n");  

        sippy_get_string( bufTo, sizeof(bufTo) );
        sippy_get_string( bufFrom, sizeof(bufFrom) );
        sippy_get_string( buf, sizeof(buf) );

        gaim_debug(GAIM_DEBUG_INFO,"sippy","got an IM from=%s to=%s data=%s\n",bufFrom,bufTo,buf);  

        serv_got_im(gc,bufFrom,buf,0,time(NULL)); 
     }
     break;
     
     case SIMPLE_LOGIN_STATUS:
     {
        unsigned char success;
        int sipCode;
        
        /* bool success, int sipCode, data message */
        sippy_get_bool( &success );
        sippy_get_int( &sipCode );
        sippy_get_string( buf, sizeof(buf) );  
 
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got a LOGIN_STATUS status=%d msg=%s\n",sipCode,buf);
	if (gaim_connection_get_state(gc) != GAIM_CONNECTED)
	{
          if (success)
          {
            gaim_connection_update_progress(gc,_("Connecting"),1,2);
            gaim_connection_set_state(gc, GAIM_CONNECTED);
          }
          else
          {
            gaim_connection_error(gc, _(buf));
          }
	}
     }
     break;
     
     case SIMPLE_PRESENCE: /* uri aor, bool  available, Data status */
     { 
        unsigned char open;
	int lastReportedUCStatus;
        
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got a PRES messages from gag\n");

        sippy_get_string( bufFrom, sizeof(bufFrom) );
        sippy_get_bool( &open );
        sippy_get_string( buf, sizeof(buf) );
        
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got a PRES messages from gag from=%s open=%d, msg=%s\n",bufFrom,open,buf);

        {
	  struct simple_connection_cache *sc_cache = gc->proto_data;
	  struct simple_friend_cache *sf;
	  
	  sf = g_hash_table_lookup(sc_cache->friends,bufFrom);
	  if (!sf) {
	    sf = simple_friend_cache_new();
	    g_hash_table_insert(sc_cache->friends,g_strdup(bufFrom),sf);
	  }
          if (sf->status_string)
	  {
	    g_free(sf->status_string);
	  } 
	  sf->status_string = g_strdup(buf);

	  lastReportedUCStatus = (sf->status_int ^= 2);
	} 

	/* AFAICT, there is a half-done change to the use of
	 * the last argument to serv_got_update that is messing
	 * up Yahoo as well as us. The code above the prpl abstraction
	 * claims the integer is ours to do with as we please, but they
	 * use the lowest order bit to mean available or not.
	 *
	 * Other code looks for changes to this integer - if it has
	 * not changed it shortcuts all the GUI updates. So...
	 * We're going to game gaim for now by toggling the second
	 * lowest order bit each time we call this function.
         *
         * TODO: This was true in the gaim 0.71 code - need to review to
         * see if this is still appropriate.
	 */

        serv_got_update(gc, bufFrom, (int)open, 0, 0, 0, lastReportedUCStatus);

     }
     break;
     
     case SIMPLE_HELLO: /* bool ok */
     {
        unsigned char ok;
        sippy_get_bool( &ok ); 
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got a HELLO ok=%d\n",ok);
     }
     
     case SIMPLE_ERROR:
     { 
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got an ERROR messages from gag\n");
        sippy_get_string( buf, sizeof(buf) );
        gaim_debug(GAIM_DEBUG_INFO,"sippy","gag ERROR %s\n",buf);
        gaim_request_action(gc, _("SIP Error"), _("SIP Error"), buf, 
                             0, NULL, 1, _("Okay"), 0);
     }
     break;
     
     default:
        resip_assert(0);
  }
}
예제 #10
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);
}
예제 #11
0
static gboolean
_parse_data(TrepiaSession *session, char *buf)
{
	GHashTable *info;
	GaimAccount *account;
	TrepiaMessageType type = 0;
	TrepiaProfile *profile = NULL;
	int ret;
	char *buffer;
	GaimBuddy *b;
	int id = 0;
	const char *value;
	char *username;
	int *int_p;
	GMainContext *ctx;

	account = gaim_connection_get_account(session->gc);

	ret = __parse_message(buf, &type, &info);

	if (ret == 1)
		return TRUE;

	if (info != NULL) {
		switch (type) {
			case TREPIA_USER_LIST:
				gaim_connection_update_progress(session->gc,
						_("Retrieving buddy list"), 2, TREPIA_CONNECT_STEPS);

				gaim_connection_set_state(session->gc, GAIM_CONNECTED);
				serv_finish_login(session->gc);
				break;

			case TREPIA_MSG_INCOMING: /* Incoming Message */
				id = atoi(g_hash_table_lookup(info, "a"));

				profile = g_hash_table_lookup(session->user_profiles, &id);
				serv_got_im(session->gc,
							trepia_profile_get_login(profile),
							(char *)g_hash_table_lookup(info, "b"),
							0, time(NULL));
				break;

			case TREPIA_MEMBER_UPDATE:
				profile = trepia_profile_new();

				if ((value = g_hash_table_lookup(info, "a")) != NULL) {
					id = atoi(value);
					trepia_profile_set_id(profile, id);
				}

				if ((value = g_hash_table_lookup(info, "b")) != NULL)
					trepia_profile_set_login_time(profile, atoi(value));

				if ((value = g_hash_table_lookup(info, "c")) != NULL)
					trepia_profile_set_type(profile, atoi(value));
				else
					trepia_profile_set_type(profile, 2);

				session->pending_users = g_list_append(session->pending_users,
													   profile);


#if 0
				if (trepia_profile_get_type(profile) == 1) {
					buffer = g_strdup_printf(
						"<D>"
						"<a>%d</a>"
						"<b>1</b>"
						"</D>",
						id);
				}
				else {
#endif
					buffer = g_strdup_printf(
						"<D>"
						"<a>%d</a>"
						"<b>1</b>"
						"</D>"
						"<D>"
						"<a>%d</a>"
						"<b>2</b>"
						"</D>",
						id,
						id);
#if 0
				}
#endif

				if (trepia_write(session->fd, buffer, strlen(buffer)) < 0) {
					gaim_connection_error(session->gc, _("Write error"));
					g_free(buffer);
					return 1;
				}

				g_free(buffer);
				break;

			case TREPIA_MEMBER_PROFILE:
				if ((value = g_hash_table_lookup(info, "a")) != NULL) {
					GList *l;

					id = atoi(value);

					for (l = session->pending_users; l != NULL; l = l->next) {
						profile = l->data;

						if (trepia_profile_get_id(profile) == id)
							break;

						profile = NULL;
					}
				}
				else
					break;

				if (profile == NULL) {
					profile = g_hash_table_lookup(session->user_profiles, &id);

					if (profile == NULL)
						break;
				}

				/* Age */
				if ((value = g_hash_table_lookup(info, "m")) != NULL)
					trepia_profile_set_age(profile, atoi(value));

				/* ICQ */
				if ((value = g_hash_table_lookup(info, "i")) != NULL)
					trepia_profile_set_icq(profile, atoi(value));

				/* Sex */
				if ((value = g_hash_table_lookup(info, "n")) != NULL)
					trepia_profile_set_sex(profile, *value);

				/* Location */
				if ((value = g_hash_table_lookup(info, "p")) != NULL)
					trepia_profile_set_location(profile, value);

				/* First Name */
				if ((value = g_hash_table_lookup(info, "g")) != NULL)
					trepia_profile_set_first_name(profile, value);

				/* Last Name */
				if ((value = g_hash_table_lookup(info, "h")) != NULL)
					trepia_profile_set_last_name(profile, value);

				/* Profile */
				if ((value = g_hash_table_lookup(info, "o")) != NULL)
					trepia_profile_set_profile(profile, value);

				/* E-mail */
				if ((value = g_hash_table_lookup(info, "e")) != NULL)
					trepia_profile_set_email(profile, value);

				/* AIM */
				if ((value = g_hash_table_lookup(info, "j")) != NULL)
					trepia_profile_set_aim(profile, value);

				/* MSN */
				if ((value = g_hash_table_lookup(info, "k")) != NULL)
					trepia_profile_set_msn(profile, value);

				/* Yahoo */
				if ((value = g_hash_table_lookup(info, "l")) != NULL)
					trepia_profile_set_yahoo(profile, value);

				/* Homepage */
				if ((value = g_hash_table_lookup(info, "f")) != NULL)
					trepia_profile_set_homepage(profile, value);

				/* Country */
				if ((value = g_hash_table_lookup(info, "r")) != NULL)
					trepia_profile_set_country(profile, value);

				/* State */
				if ((value = g_hash_table_lookup(info, "s")) != NULL)
					trepia_profile_set_state(profile, value);

				/* City */
				if ((value = g_hash_table_lookup(info, "t")) != NULL)
					trepia_profile_set_city(profile, value);

				/* Languages */
				if ((value = g_hash_table_lookup(info, "u")) != NULL)
					trepia_profile_set_languages(profile, value);

				/* School */
				if ((value = g_hash_table_lookup(info, "v")) != NULL)
					trepia_profile_set_school(profile, value);

				/* Company */
				if ((value = g_hash_table_lookup(info, "w")) != NULL)
					trepia_profile_set_company(profile, value);

				/* Login Name */
				if ((value = g_hash_table_lookup(info, "d")) != NULL) {
					trepia_profile_set_login(profile, value);
					username = g_strdup(value);
				}
				else if ((value = trepia_profile_get_login(profile)) != NULL) {
					username = g_strdup(value);
				}
				else {
					username = g_strdup_printf("%d", id);
					trepia_profile_set_login(profile, username);
				}

				b = gaim_find_buddy(account, username);

				if (b == NULL) {
					GaimGroup *g;

					g = gaim_find_group(_("Local Users"));

					if (g == NULL) {
						g = gaim_group_new(_("Local Users"));
						gaim_blist_add_group(g, NULL);
					}

					b = gaim_buddy_new(account, username, NULL);

					gaim_blist_add_buddy(b, NULL, g, NULL);
				}

				profile->buddy = b;

				b->proto_data = profile;

				session->pending_users = g_list_remove(session->pending_users,
													   profile);

				int_p = g_new0(int, 1);
				*int_p = id;
				g_hash_table_insert(session->user_profiles, int_p, profile);

				serv_got_update(session->gc,
								username, TRUE, 0,
								trepia_profile_get_login_time(profile), 0, 0);

				/* Buddy Icon */
				if ((value = g_hash_table_lookup(info, "q")) != NULL) {
					char *icon;
					int icon_len;

					gaim_base64_decode(value, &icon, &icon_len);

					gaim_buddy_icons_set_for_user(session->gc->account,
							username, icon, icon_len);

					g_free(icon);

					serv_got_update(session->gc, username, TRUE, 0, 0, 0, 0);
				}

				/*
				 * XXX
				 * This does nothing when using a non-gtk event loop.
				 * What is it supposed to accomplish anyway?
				 */
				ctx = g_main_context_default();

				while (g_main_context_pending(ctx))
					g_main_context_iteration(ctx, FALSE);

				g_free(username);

				break;

			case TREPIA_MEMBER_OFFLINE:
				if ((value = g_hash_table_lookup(info, "a")) != NULL)
					id = atoi(value);
				else
					break;

				profile = g_hash_table_lookup(session->user_profiles, &id);

				if (profile == NULL)
					break;

				g_hash_table_remove(session->user_profiles, &id);

				b = profile->buddy;

				if (b != NULL)
					serv_got_update(session->gc,
									trepia_profile_get_login(profile),
									FALSE, 0, 0, 0, 0);

				gaim_blist_remove_buddy(b);

				break;

			default:
				break;
		}

		g_hash_table_destroy(info);
	}
	else {