3
icqtlvinforequesttask.cpp - SNAC 0x15 parsing for full user info (TLV based)
5
Copyright (c) 2007 Roman Jarosz <kedgedev@centrum.cz>
7
Kopete (c) 2007 by the Kopete developers <kopete-devel@kde.org>
9
*************************************************************************
11
* This library is free software; you can redistribute it and/or *
12
* modify it under the terms of the GNU Lesser General Public *
13
* License as published by the Free Software Foundation; either *
14
* version 2 of the License, or (at your option) any later version. *
16
*************************************************************************
19
#include "icqtlvinforequesttask.h"
23
#include "connection.h"
27
ICQTlvInfoRequestTask::ICQTlvInfoRequestTask( Task* parent ) : ICQTask( parent )
32
ICQTlvInfoRequestTask::~ICQTlvInfoRequestTask()
36
bool ICQTlvInfoRequestTask::forMe( const Transfer* transfer ) const
38
const SnacTransfer * st = dynamic_cast<const SnacTransfer*>( transfer );
43
if ( st->snacService() != 0x0015 || st->snacSubtype() != 0x0003 || !m_contactSequenceMap.contains( st->snacRequest() ) )
46
Buffer buf( *( st->buffer() ) );
47
const_cast<ICQTlvInfoRequestTask*>( this )->parseInitialData( buf );
49
if ( requestType() == 0x07DA && requestSubType() == 0x0FB4 )
55
bool ICQTlvInfoRequestTask::take( Transfer* transfer )
57
if ( forMe( transfer ) )
59
const SnacTransfer* st = dynamic_cast<const SnacTransfer*>( transfer );
63
setTransfer( transfer );
64
TLV tlv1 = transfer->buffer()->getTLV();
65
Buffer buffer( tlv1.data, tlv1.length );
67
//FIXME this is silly. parseInitialData should take care of this for me.
68
buffer.skipBytes( 12 );
70
if ( buffer.getByte() == 0x0A )
72
kDebug(OSCAR_RAW_DEBUG) << "Received user info";
73
parse( st->snacRequest(), buffer.getLEBlock() );
74
setSuccess( 0, QString() );
78
kDebug(OSCAR_RAW_DEBUG) << "Couldn't receive user info!!!";
79
setError( 0, QString() );
88
void ICQTlvInfoRequestTask::onGo()
90
kDebug(OSCAR_RAW_DEBUG) << "Requsting full TLV user info for: " << m_userToRequestFor;
92
setSequence( client()->snacSequence() );
93
setRequestType( 0x07D0 );
94
setRequestSubType( 0x0FA0 );
98
b.startBlock( Buffer::BWord, Buffer::LittleEndian );
100
b.addDWord( 0x05b90002 );
101
b.addDWord( 0x80000000 );
102
b.addDWord( 0x00000006 );
103
b.addDWord( 0x00010002 );
104
b.addDWord( 0x00020000 );
105
b.addDWord( 0x04e20000 );
108
b.addDWord( 0x00000001 );
110
b.startBlock( Buffer::BWord );
111
b.addTLV( 0x003C, m_metaInfoId );
112
b.addTLV( 0x0032, m_userToRequestFor.toLatin1() );
117
Buffer *sendBuf = addInitialData( &b );
119
Oscar::DWORD seq = client()->snacSequence();
120
m_contactSequenceMap[seq] = m_userToRequestFor;
122
FLAP f = { 0x02, 0, 0 };
123
SNAC s = { 0x0015, 0x0002, 0, seq };
124
Transfer* t = createTransfer( f, s, sendBuf );
128
ICQFullInfo ICQTlvInfoRequestTask::fullInfoFor( const QString& contact )
130
ICQFullInfo info = m_fullInfoMap.value( contact );
131
m_fullInfoMap.remove( contact );
135
void ICQTlvInfoRequestTask::parse( Oscar::DWORD seq, const QByteArray &data )
141
QString contact = m_contactSequenceMap[seq];
144
info.setSequenceNumber( seq );
146
m_fullInfoMap[contact] = info;
148
emit receivedInfoFor( contact );
149
m_contactSequenceMap.remove( seq );
152
#include "icqtlvinforequesttask.moc"