~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to protocols/oscar/liboscar/tasks/blmlimitstask.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Kopete Oscar Protocol
 
3
    blmlimitstask - Get the BLM service limits
 
4
 
 
5
    Copyright (c) 2004 Matt Rogers <mattr@kde.org>
 
6
 
 
7
    Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
 
8
 
 
9
    *************************************************************************
 
10
    *                                                                       *
 
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.      *
 
15
    *                                                                       *
 
16
    *************************************************************************
 
17
*/
 
18
 
 
19
#include "blmlimitstask.h"
 
20
#include <kdebug.h>
 
21
#include "connection.h"
 
22
#include "transfer.h"
 
23
#include "oscartypes.h"
 
24
#include "oscarutils.h"
 
25
 
 
26
BLMLimitsTask::BLMLimitsTask( Task* parent )
 
27
 : Task( parent )
 
28
{
 
29
}
 
30
 
 
31
 
 
32
BLMLimitsTask::~BLMLimitsTask()
 
33
{
 
34
}
 
35
 
 
36
 
 
37
bool BLMLimitsTask::forMe(const Transfer* transfer) const
 
38
{
 
39
        const SnacTransfer* st = dynamic_cast<const SnacTransfer*>( transfer );
 
40
 
 
41
        if (!st)
 
42
                return false;
 
43
 
 
44
        if ( st->snacService() == 3 && st->snacSubtype() == 3 )
 
45
                return true;
 
46
        else
 
47
                return false;
 
48
}
 
49
 
 
50
bool BLMLimitsTask::take(Transfer* transfer)
 
51
{
 
52
        if ( forMe( transfer ) )
 
53
        {
 
54
                Buffer* buffer = transfer->buffer();
 
55
                while ( buffer->bytesAvailable() != 0 )
 
56
                {
 
57
                        TLV t = buffer->getTLV();
 
58
                        switch ( t.type )
 
59
                        {
 
60
                                case 0x0001:
 
61
                                        kDebug(OSCAR_RAW_DEBUG) << "Max BLM entries: " << t.data.toHex();
 
62
                                        break;
 
63
                                case 0x0002:
 
64
                                        kDebug( OSCAR_RAW_DEBUG ) << "Max watcher entries: " << t.data.toHex();
 
65
                                        break;
 
66
                                case 0x0003:
 
67
                                        kDebug( OSCAR_RAW_DEBUG ) << "Max online notifications(?): " << t.data.toHex();
 
68
                                        break;
 
69
                        }
 
70
                }
 
71
                setSuccess( 0, QString() );
 
72
                return true;
 
73
        }
 
74
        else
 
75
                return false;
 
76
}
 
77
 
 
78
void BLMLimitsTask::onGo()
 
79
{
 
80
        kDebug(OSCAR_RAW_DEBUG) << "Sending BLM limits request";
 
81
        FLAP f = { 0x02, 0, 0 };
 
82
        SNAC s = { 0x0003, 0x0002, 0x0000, client()->snacSequence() };
 
83
 
 
84
        Buffer* buffer = new Buffer();
 
85
        buffer->addTLV16( 0x0005, 0x0003 );
 
86
 
 
87
        Transfer *t = createTransfer( f, s, buffer );
 
88
        send( t );
 
89
}
 
90
 
 
91
//kate: tab-width 4; indent-mode csands;