bool OscarLoginTask::take( Transfer* transfer )
{
	if ( forMe( transfer ) )
	{
		SnacTransfer* st = dynamic_cast<SnacTransfer*>( transfer );
		if (!st)
			return false;

		Oscar::WORD subtype = st->snacSubtype();
		switch ( subtype )
		{
		case 0x0003:
			setTransfer( transfer );
			handleLoginResponse();
			setTransfer( 0 );
			return true;
			break;
		case 0x0007:
			setTransfer( transfer );
			processAuthStringReply();
			setTransfer( 0 );
			return true;
			break;
		default:
			return false;
			break;
		}

		return false;
	}
	return false;
}
Esempio n. 2
0
bool AimLoginTask::forMe( Transfer* transfer ) const
{
    SnacTransfer* st = dynamic_cast<SnacTransfer*>( transfer );

    if (!st)
        return false;

    if ( st && st->snacService() == 0x17 )
    {
        WORD subtype = st->snacSubtype();
        switch ( subtype )
        {
        case 0x0002:
        case 0x0003:
        case 0x0006:
        case 0x0007:
            return true;
            break;
        default:
            return false;
            break;
        }
    }
    return false;
}
bool ServerVersionsTask::take( Transfer* transfer )
{	
	SnacTransfer* st = dynamic_cast<SnacTransfer*> ( transfer );
	if (!st)
		return false;
	
	if ( forMe( transfer ) )
	{
		switch ( st->snacSubtype() )
		{
			case 0x03:
				setTransfer( transfer );
				handleFamilies();
				setTransfer( 0 );
				return true;
				break;
			case 0x18:
				setTransfer( transfer );
				kDebug(OSCAR_RAW_DEBUG) << "Ignoring server versions";
				setSuccess( 0, QString() );
				setTransfer( 0 );
				return true;
				break;
			default:
				return false;
		}
	}
	return false;
}
Esempio n. 4
0
bool SSIAuthTask::take( Transfer* t )
{
	if ( forMe( t ) )
	{
		setTransfer( t );
		SnacTransfer* st = dynamic_cast<SnacTransfer*> ( t );
		
		switch ( st->snacSubtype() )
		{
			case 0x0015: // Future authorization granted
				handleFutureAuthGranted();
				break;
			case 0x0019: // Authorization request
				handleAuthRequested();
				break;
			case 0x001b: // Authorization reply
				handleAuthReplied();
				break;
			case 0x001c: // "You were added" message
				handleAddedMessage();
				break;
		}
		setTransfer( 0 );
		return true;
	}
	return false;
}
bool SSIModifyTask::take( Transfer* transfer )
{
	if ( forMe( transfer ) )
	{
		SnacTransfer* st = dynamic_cast<SnacTransfer*>( transfer );
		if ( st )
		{
			setTransfer( transfer );

			if ( st->snacSubtype() == 0x0008 )
				handleContactAdd();
			else if ( st->snacSubtype() == 0x0009 )
				handleContactUpdate();
			else if ( st->snacSubtype() == 0x000A )
				handleContactRemove();
			else if ( st->snacSubtype() == 0x000E )
				handleContactAck();

			setTransfer( 0 );
		}
		return true;
	}
	else
		return false;
}
Esempio n. 6
0
bool UserInfoTask::take( Transfer * transfer )
{
	if ( forMe( transfer ) )
	{
		setTransfer( transfer );
		Oscar::DWORD seq = 0;
		SnacTransfer* st = dynamic_cast<SnacTransfer*>( transfer );
		if ( st )
			seq = st->snacRequest();

		if ( seq != 0 )
		{
			//AFAIK location info packets always have user info
			Buffer* b = transfer->buffer();
			UserDetails ud;
			ud.fill( b );
			m_sequenceInfoMap[seq] = ud;
			emit gotInfo( seq );

			QList<TLV> list = b->getTLVList();
			QList<TLV>::iterator it = list.begin(), itEnd = list.end();
			QString profile;
			QString away;
			for ( ; it != itEnd; ++it )
			{
				switch( ( *it ).type )
				{
				case 0x0001: //profile text encoding
					kDebug(OSCAR_RAW_DEBUG) << "text encoding is " << QString( ( *it ).data );
					break;
				case 0x0002: //profile text
					kDebug(OSCAR_RAW_DEBUG) << "The profile is '" << QString( ( *it ).data ) << "'";
					profile = QString( ( *it ).data ); // aim always seems to use us-ascii encoding
					emit receivedProfile( m_contactSequenceMap[seq], profile );
					break;
				case 0x0003: //away message encoding
					kDebug(OSCAR_RAW_DEBUG) << "Away message encoding is " << QString( ( *it ).data );
					break;
				case 0x0004: //away message
					kDebug(OSCAR_RAW_DEBUG) << "Away message is '" << QString( ( *it ).data ) << "'";
					away = QString( (*it ).data ); // aim always seems to use us-ascii encoding
					emit receivedAwayMessage( m_contactSequenceMap[seq], away );
					break;
				case 0x0005: //capabilities
					break;
				default: //unknown
					kDebug(14151) << "Unknown user info type " << ( *it ).type;
					break;
				};
			}
			list.clear();
		}
		setTransfer( 0 );
		return true;
	}
	return false;
}
Esempio n. 7
0
void AimLoginTask::handleLoginResponse()
{
    kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "RECV SNAC 0x17, 0x07 - AIM Login Response" << endl;

    SnacTransfer* st = dynamic_cast<SnacTransfer*> ( transfer() );

    if ( !st )
    {
        setError( -1 , QString::null );
        return;
    }

    QValueList<TLV> tlvList = st->buffer()->getTLVList();

    TLV uin = findTLV( tlvList, 0x0001 );
    if ( uin )
    {
        kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "found TLV(1) [SN], SN=" << QString( uin.data ) << endl;
    }

    TLV err = findTLV( tlvList, 0x0008 );

    if ( err )
    {
        WORD errorNum = ( ( err.data[0] << 8 ) | err.data[1] );

        kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << k_funcinfo << "found TLV(8) [ERROR] error= " <<
                                 errorNum << endl;
        Oscar::SNAC s = { 0, 0, 0, 0 };
        client()->fatalTaskError( s, errorNum );
        setError( errorNum, QString::null );
        return; //if there's an error, we'll need to disconnect anyways
    }

    TLV server = findTLV( tlvList, 0x0005 );
    if ( server )
    {
        QString ip = QString( server.data );
        kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "found TLV(5) [SERVER] " << ip << endl;
        int index = ip.find( ':' );
        m_bosHost = ip.left( index );
        ip.remove( 0 , index+1 ); //get rid of the colon and everything before it
        m_bosPort = ip.left(4); //we only need 4 bytes
        kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "We should reconnect to server '" << m_bosHost <<
                                 "' on port " << m_bosPort << endl;
    }

    TLV cookie = findTLV( tlvList, 0x0006 );
    if ( cookie )
    {
        kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "found TLV(6) [COOKIE]" << endl;
        m_cookie.duplicate( cookie.data );
        setSuccess( 0, QString::null );
    }
    tlvList.clear();
}
bool OwnUserInfoTask::take( Transfer* transfer )
{
	if ( forMe( transfer ) )
	{
		SnacTransfer* st = dynamic_cast<SnacTransfer*>( transfer );
		if ( !st )
			return false;
		
		Buffer* b = transfer->buffer();
		if ( st->snacSubtype() == 0x0F )
		{
			UserDetails ud;
			ud.fill( b );
			m_details = ud;
			emit gotInfo();
			setSuccess( 0, QString() );
			return true;
		}
		else
		{
			bool needUpload = false;
			Oscar::WORD infoType = b->getWord();
			if ( infoType == 0x0000 || infoType == 0x0001 )
			{
				Oscar::BYTE flags = b->getByte();
				if ( flags == 0x41 )  //we need to do a buddy upload when bit 8 = 1
					needUpload = true;
				
				QByteArray qba;
				if ( b->bytesAvailable() != 0 )
				{ //buffer might be empty if flags bit 8 = 1
					Oscar::BYTE checksumLength = b->getByte();
					qba = b->getBlock( checksumLength );
					kDebug(OSCAR_RAW_DEBUG) << "Self icon checksum: " << qba.toHex();
				}
				
				if ( needUpload )
				{
					kDebug(OSCAR_RAW_DEBUG) << "Buddy icon upload requested";
					emit buddyIconUploadRequested();
				}
				else
				{
					kDebug(OSCAR_RAW_DEBUG) << "no item for hash found";
				}
			}
			
			if ( infoType == 0x0002 )
			{
				QString availableMsg( b->getBSTR() );
				kDebug(OSCAR_RAW_DEBUG) << "self available message: ";
			}
			
			setSuccess( 0, QString() );
			return true;
		}
		
	}

	return false;
}
void OscarLoginTask::handleLoginResponse()
{
	kDebug(OSCAR_RAW_DEBUG) << "RECV SNAC 0x17, 0x07 - AIM Login Response";

	SnacTransfer* st = dynamic_cast<SnacTransfer*> ( transfer() );

	if ( !st )
	{
		setError( -1 , QString() );
		return;
	}

	QList<TLV> tlvList = st->buffer()->getTLVList();

	TLV uin = findTLV( tlvList, 0x0001 );
	if ( uin )
	{
		kDebug(OSCAR_RAW_DEBUG) << "found TLV(1) [SN], SN=" << QString( uin.data );
	}

	TLV err = findTLV( tlvList, 0x0008 );	
	if ( err )
	{
		Oscar::WORD errorNum = ( ( err.data[0] << 8 ) | err.data[1] );

		kDebug(OSCAR_RAW_DEBUG) << "found TLV(8) [ERROR] error= " << errorNum;
		Oscar::SNAC s = { 0, 0, 0, 0 };
		client()->fatalTaskError( s, errorNum );
		setError( errorNum, QString() );
		return; //if there's an error, we'll need to disconnect anyways
	}

	TLV server = findTLV( tlvList, 0x0005 );
	if ( server )
	{
		kDebug(OSCAR_RAW_DEBUG) << "found TLV(5) [SERVER] " << QString( server.data );
		QString ip = QString( server.data );
		int index = ip.indexOf( ':' );
		m_bosHost = ip.left( index );
		ip.remove( 0 , index+1 ); //get rid of the colon and everything before it
		m_bosPort = ip;
	}

	TLV cookie = findTLV( tlvList, 0x0006 );
	if ( cookie )
	{
		kDebug(OSCAR_RAW_DEBUG) << "found TLV(6) [COOKIE]";
		m_cookie = cookie.data;
	}

	TLV sslcert = findTLV( tlvList, 141 );
	if ( sslcert )
	{
		kDebug(OSCAR_RAW_DEBUG) << "found TLV(141) [SSLCERT]";
		m_bosSSLName = sslcert.data;
	}

	TLV ssl = findTLV( tlvList, 142 );
	{
		kDebug(OSCAR_RAW_DEBUG) << "found TLV(142) [SSL] " << (int)ssl.data[0];
		m_bosEncrypted = ssl.data[0];
	}

	tlvList.clear();

	if ( m_bosHost.isEmpty() )
	{
		kWarning(OSCAR_RAW_DEBUG) << "Empty host address!";
		
		Oscar::SNAC s = { 0, 0, 0, 0 };
		client()->fatalTaskError( s, 0 );
		setError( 0, QString() );
		return;
	}
	
	kDebug( OSCAR_RAW_DEBUG ) << "We should reconnect to server '"
		<< m_bosHost << "' on port " << m_bosPort << ( m_bosEncrypted ? " with " : " without " ) << "SSL" << endl;
	setSuccess( 0, QString() );
}