summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/oscar/liboscar/rateclassmanager.h
blob: c94a1e5f8aa21ef7fae5a94f01de7575bb08c767 (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
/*
    Kopete Oscar Protocol
    rateclassmanager.h - Manages the rates we get from the OSCAR server

    Copyright (c) 2004 Matt Rogers <mattr@kde.org>

    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.      *
    *                                                                       *
    *************************************************************************
*/

#ifndef RATECLASSMANAGER_H
#define RATECLASSMANAGER_H

#include <tqobject.h>
#include <tqvaluelist.h>
#include <tqmap.h>
#include "oscartypes.h"

class Transfer;
class SnacTransfer;
class RateClass;
class Connection;
class RateClassManagerPrivate;


class RateClassManager : public TQObject
{
TQ_OBJECT
  
public:
	RateClassManager( Connection* parent, const char* name = 0 );
	~RateClassManager();

	/** Reset the rate manager */
	void reset();

	/** Tell the rate manager about the new class */
	void registerClass( RateClass* );

	//! Check if we can send the packet right away
	bool canSend( Transfer* t ) const;

	//! Queue a transfer for sending later
	void queue( Transfer* t );

	/** Get the list of rate classes */
	TQValueList<RateClass*> classList() const;
	
	/** Recalculate the rate levels for all the classes */
	void recalcRateLevels();

	/**
	 * Find the rate class for the snac and
	 * calculate time until we get to initial level
	 * \return the time in milliseconds that we need to wait
	 */
	int timeToInitialLevel( Oscar::SNAC s );

public slots:

	void transferReady( Transfer* );

private:

	/** Find the rate class for the transfer */
	RateClass* findRateClass( SnacTransfer* st ) const;

private:

	RateClassManagerPrivate* d;

};

#endif