summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/oscar/liboscar/icqtask.cpp
blob: 1c8d98aec394d45e0b7d82ede2bc6a9dc53dc520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
   Kopete Oscar Protocol
   icqtask.cpp - SNAC 0x15 parsing 

   Copyright (c) 2004 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>

   Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

   *************************************************************************
   *                                                                       *
   * This library is free software; you can redistribute it and/or         *
   * modify it under the terms of the GNU Lesser General Public            *
   * License as published by the Free Software Foundation; either          *
   * version 2 of the License, or (at your option) any later version.      *
   *                                                                       *
   *************************************************************************
*/

#include "icqtask.h"
#include "buffer.h"
#include "connection.h"

#include <tqstring.h>

#include <kdebug.h>

ICQTask::ICQTask( Task * tqparent )
	: Task( tqparent )
{
	m_icquin = client()->userId().toULong();
	m_sequence = 0;
	m_requestType = 0xFFFF;
	m_requestSubType = 0xFFFF;
}

ICQTask::~ ICQTask()
{
}

void ICQTask::onGo()
{
}

bool ICQTask::forMe( const Transfer *t ) const
{
	Q_UNUSED( t );
	return false;
}

bool ICQTask::take( Transfer* t )
{
	Q_UNUSED( t );
	return false;
}

void ICQTask::parseInitialData( Buffer buf )
{
	int tlvLength = 0;
	WORD sequence = 0;
	TLV tlv1 = buf.getTLV();
	Buffer tlv1Buffer(tlv1.data, tlv1.length);
	tlvLength = tlv1Buffer.getLEWord(); //FIXME handle the data chunk size
	m_icquin = tlv1Buffer.getLEDWord(); //nice ICQ UIN
	m_requestType = tlv1Buffer.getLEWord(); //request type
	sequence = tlv1Buffer.getLEWord();
	if ( m_requestType == 0x07DA ) //there's an extra data subtype
		m_requestSubType = tlv1Buffer.getLEWord();
	else
		m_requestSubType = 0xFFFF;

/*kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "uin: " << m_icquin << " sequence: " << sequence
		<<" request type: 0x" << TQString::number( m_requestType, 16 )
		<< " request sub type: 0x" << TQString::number( m_requestSubType, 16 ) << endl;*/
}

Buffer* ICQTask::addInitialData( Buffer* buf ) const
{
	if ( m_requestType == 0xFFFF )
	{ //something very wrong here
		return 0;
	}
	
	Buffer* tlvData = new Buffer();
	tlvData->addLEDWord( m_icquin ); // UIN
	tlvData->addLEWord( m_requestType ); // request type
	tlvData->addLEWord( m_sequence );
	
	if ( m_requestSubType != 0xFFFF )
		tlvData->addLEWord( m_requestSubType );
	
	/*kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "uin: " << m_icquin << " sequence: " << sequence
		<<" request type: 0x" << TQString::number( m_requestType, 16 )
		<< " request sub type: 0x" << TQString::number( m_requestSubType, 16 ) << endl; */
	if ( buf != 0 )
		tlvData->addString( buf->buffer(), buf->length() );
	
	Buffer* newBuffer = new Buffer();
	//add TLV 1
	newBuffer->addWord( 0x0001 ); //TLV 1
	newBuffer->addWord( tlvData->length() + 2 ); //TLV length
	newBuffer->addLEWord( tlvData->length() ); // data chunk size
	newBuffer->addString( tlvData->buffer(), tlvData->length() );
	
	delete tlvData;

	return newBuffer;
}

DWORD ICQTask::uin() const
{
	return m_icquin;
}

void ICQTask::setUin( DWORD uin )
{
	m_icquin = uin;
}

WORD ICQTask::sequence() const
{
	return m_sequence;
}

void ICQTask::setSequence( WORD sequence )
{
	m_sequence = sequence;
}

DWORD ICQTask::requestType() const
{
	return m_requestType;
}

void ICQTask::setRequestType( WORD type )
{
	m_requestType = type;
}

DWORD ICQTask::requestSubType() const
{
	return m_requestSubType;
}

void ICQTask::setRequestSubType( WORD subType )
{
	m_requestSubType = subType;
}

#include "icqtask.moc"

//kate: space-indent off; tab-width 4; replace-tabs off; indent-mode csands;