This library is free software you can redistribute it and or modify it

  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
/**
* 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.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package ru.caffeineim.protocols.icq.packet.received.generic;
import ru.caffeineim.protocols.icq.RawData;
import ru.caffeineim.protocols.icq.core.OscarConnection;
import ru.caffeineim.protocols.icq.packet.received.ReceivedPacket;
import ru.caffeineim.protocols.icq.integration.events.RateChangedEvent;
import ru.caffeineim.protocols.icq.integration.listeners.GenericListener;
/**
* <p>Created by
* @author Fabrice Michellonet
*/
public class RateChanged__1_10 extends ReceivedPacket
{
/*
0x0001 Rate limits parameters changed
0x0002 Rate limits warning (current level < alert level)
0x0003 Rate limit hit (current level < limit level)
0x0004 Rate limit clear (current level become > clear level)
*/
private RawData messageCode;
private RawData rateClass;
private RawData clearLevel;
private RawData alertLevel;
private RawData limitLevel;
private RawData disctLevel;
private RawData currsLevel;
private RawData maxmsLevel;
public RateChanged__1_10(byte[] array)
{
super(array, true);
int position = 0;
byte[] data = getSnac().getDataFieldByteArray();
if ((getSnac().getFlag0() & 0x80) != 0)
{
position += 2 + (int) new RawData(data, position, 2).getValue();
}
messageCode = new RawData(data, position, 2);
position += 2;
rateClass = new RawData(data, position, 2);
position += 2;
// Window size
position += 4;
clearLevel = new RawData(data, position, 4);
position += 4;
alertLevel = new RawData(data, position, 4);
position += 4;
limitLevel = new RawData(data, position, 4);
position += 4;
disctLevel = new RawData(data, position, 4);
position += 4;
currsLevel = new RawData(data, position, 4);
position += 4;
maxmsLevel = new RawData(data, position, 4);
position += 4;
}
public void execute(OscarConnection connection)
{
}
public void notifyEvent(OscarConnection connection)
{
RateChangedEvent e = new RateChangedEvent(this);
for (int i = 0; i < connection.getGenericListeners().size(); i++)
{
GenericListener l = (GenericListener) connection.getGenericListeners().get(i);
l.onRateChanged(e);
}
}
public int getMessageCode()
{
return messageCode.getValue();
}
public boolean isChange()
{
return getMessageCode() == 0x01;
}
public boolean isWarning()
{
return getMessageCode() == 0x02;
}
public boolean isHit()
{
return getMessageCode() == 0x03;
}
public boolean isClear()
{
return getMessageCode() == 0x04;
}
public int getRateClass()
{
return rateClass.getValue();
}
public int getClearLevel()
{
return clearLevel.getValue();
}
public int getAlertLevel()
{
return alertLevel.getValue();
}
public int getCurrentLevel()
{
return currsLevel.getValue();
}
public int getLimitLevel()
{
return limitLevel.getValue();
}
}