/**
* 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();
}
}