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
|
/*
Kopete Oscar Protocol
icbmparamstask.cpp - Get the ICBM parameters
Copyright (c) 2004 Matt Rogers <[email protected]>
Kopete (c) 2002-2004 by the Kopete developers <[email protected]>
*************************************************************************
* *
* 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 "icbmparamstask.h"
#include <kdebug.h>
#include "connection.h"
#include "oscartypes.h"
#include "transfer.h"
#include "oscarutils.h"
#include "buffer.h"
ICBMParamsTask::ICBMParamsTask( Task* parent )
: Task( parent )
{}
ICBMParamsTask::~ICBMParamsTask()
{}
bool ICBMParamsTask::forMe( const Transfer* transfer ) const
{
const SnacTransfer* st = dynamic_cast<const SnacTransfer*>( transfer );
if (!st)
return false;
if ( st->snacService() == 4 && st->snacSubtype() == 5 )
return true;
else
return false;
}
bool ICBMParamsTask::take( Transfer* transfer )
{
if ( forMe( transfer ) )
{
setTransfer( transfer );
handleICBMParameters();
setTransfer( 0 );
return true;
}
return false;
}
void ICBMParamsTask::onGo()
{
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Sending ICBM Parameters request" << endl;
FLAP f = { 0x02, 0, 0 };
SNAC s = { 0x0004, 0x0004, 0x0000, client()->snacSequence() };
Buffer* buffer = new Buffer();
Transfer* st = createTransfer( f, s, buffer );
send( st );
}
void ICBMParamsTask::handleICBMParameters()
{
Buffer* buffer = transfer()->buffer();
WORD channel = buffer->getWord();
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "channel=" << channel << endl;
/**
* bit1: messages allowed for specified channel
* bit2: missed calls notifications enabled for specified channel
* bit4: client supports typing notifications
*/
DWORD messageFlags = buffer->getDWord();
WORD maxMessageSnacSize = buffer->getWord();
WORD maxSendWarnLvl = buffer->getWord(); // max sender Warning Level
WORD maxRecvWarnLvl = buffer->getWord(); // max Receiver Warning Level
WORD minMsgInterval = buffer->getWord(); // minimum message interval (msec)
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "messageFlags = " << messageFlags << endl;
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "maxMessageSnacSize = " << maxMessageSnacSize << endl;
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "maxSendWarnLvl = " << maxSendWarnLvl << endl;
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "maxRecvWarnLvl = " << maxRecvWarnLvl << endl;
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "minMsgInterval = " << minMsgInterval << endl;
/*WORD unknown = */buffer->getWord();
// Now we set our own parameters.
// The ICBM parameters have to be set up seperately for each channel.
// Some clients (namely Trillian) might refuse sending on channels that were not set up.
sendMessageParams( 0x01 );
sendMessageParams( 0x02 );
sendMessageParams( 0x04 );
}
void ICBMParamsTask::sendMessageParams( int channel )
{
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Sending ICBM parameters for channel " << channel << endl;
FLAP f = { 0x02, 0, 0 };
SNAC s = { 0x0004, 0x0002, 0x0000, client()->snacSequence() };
Buffer* buffer = new Buffer();
// the channel for which to set up the parameters
buffer->addWord( channel );
//these are all read-write
// channel-flags
// bit 1 : messages allowed (always 1 or you cannot send IMs)
// bit 2 : missed call notifications enabled
// bit 4 : typing notifications enabled
if ( channel == 1 )
buffer->addDWord(0x0000000B);
else
buffer->addDWord(0x00000003);
//max message length (8000 bytes)
buffer->addWord(0x1f40);
//max sender warning level (999)
buffer->addWord(0x03e7);
//max receiver warning level (999)
buffer->addWord(0x03e7);
//min message interval limit (0 msec)
buffer->addWord(0x0000);
// unknown parameter
buffer->addWord(0x0000);
Transfer* st = createTransfer( f, s, buffer );
send( st );
setSuccess( 0, TQString::null );
}
//kate: tab-width 4; indent-mode csands;
|