2
rateclass.h - Oscar Rate Limiting Implementation
4
Copyright (c) 2004 by Tom Linsky <twl6@po.cwru.edu>
5
Copyright (c) 2004 by Matt Rogers <mattr@k
6
Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
8
*************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
*************************************************************************
21
#include "oscartypes.h"
24
#include <qdatetime.h>
26
#include "liboscar_export.h"
28
const int RATE_SAFETY_TIME = 50;
38
class LIBOSCAR_EXPORT RateClass : public QObject
42
RateClass( QObject* parent = 0 );
45
/** Accessor for classid */
46
Oscar::WORD id() const;
48
/** Sets rate information */
49
void setRateInfo( Oscar::RateInfo newRateInfo );
51
/** Gets rate information */
52
Oscar::RateInfo getRateInfo();
54
/** Add a SNAC to the rate class */
55
void addMember( const Oscar::SNAC& s );
57
/** Adds rate class members */
58
void addMember( Oscar::WORD family, Oscar::WORD subtype );
60
/** Tells whether the passed snac is a member of this rate class */
61
bool isMember( const Oscar::SNAC& s ) const;
64
* Tells whether the passed family and subtype combo is a member
67
bool isMember( Oscar::WORD family, Oscar::WORD subtype ) const;
69
/** Add a packet to the queue */
70
void enqueue( Transfer* );
72
/** Takes a packet off the front of the queue */
75
/** Check if the queue is empty */
76
bool queueIsEmpty() const;
79
* Calulate the time until we can send again
80
* Uses the first packet on the queue to determine the time since that's
81
* the packet that will get sent.
82
* \return the time in milliseconds that we need to wait
87
* Calulate the time until we get to initial level
88
* \return the time in milliseconds that we need to wait
90
int timeToInitialLevel();
93
* Calculates a new rate level and updates the rate class' current level
96
void updateRateInfo();
99
* Dump the current packet queue. These packets will not be sent. Used
106
/** Tell the rate class manager we're ready to send */
107
void dataReady( Transfer* );
111
/** Calculate our new rate level */
112
Oscar::DWORD calcNewLevel( int timeDifference ) const;
114
/** sets up the timer for the transfer just added to the queue */
119
* Send the packet. Basically emits dataReady for the first transfer
125
Oscar::RateInfo m_rateInfo;
126
QList<SnacPair> m_members;
127
QList<Transfer*> m_packetQueue;
130
// we are waiting for the QTimer::singleShot() to send
131
bool m_waitingToSend;
136
//kate: tab-width 4; indent-mode csands;