OffgoingUser__3_12.java :  » App » android-chatty » ru » caffeineim » protocols » icq » packet » received » byddylist » Android Open Source

Android Open Source » App » android chatty 
android chatty » ru » caffeineim » protocols » icq » packet » received » byddylist » OffgoingUser__3_12.java
/**
 * 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.byddylist;

import java.io.DataInputStream;
import java.io.IOException;

import android.util.Log;
import ru.caffeineim.protocols.icq.RawData;
import ru.caffeineim.protocols.icq.core.OscarConnection;
import ru.caffeineim.protocols.icq.exceptions.BadPacketException;
import ru.caffeineim.protocols.icq.integration.events.OffgoingUserEvent;
import ru.caffeineim.protocols.icq.integration.listeners.UserStatusListener;
import ru.caffeineim.protocols.icq.packet.received.ReceivedPacket;

/**
 * <p>
 * Created by
 * 
 * @author Fabrice Michellonet
 */
public class OffgoingUser__3_12 extends ReceivedPacket {

  private static final String LOG_TAG = "ICQ:OffgoingUser__3_12";

  private RawData userId;

  public OffgoingUser__3_12(DataInputStream strm) throws IOException, BadPacketException {
    super(strm, true);
    int position = 0;

    byte[] data = getSnac().getDataFieldByteArray();

    /* Retreiving user id */
    RawData idLen = new RawData(data, position, 1);
    position++;
    userId = new RawData(data, position, idLen.getValue());
  }

  public void notifyEvent(OscarConnection connection) {
    OffgoingUserEvent e = new OffgoingUserEvent(this);
    for (int i = 0; i < connection.getUserStatusListeners().size(); i++) {
      UserStatusListener l = (UserStatusListener) connection
          .getUserStatusListeners().get(i);
      Log.d(LOG_TAG, "notify listener " + l.getClass().getName()
          + " onOffgoingUser()");
      l.onOffgoingUser(e);
    }
  }

  public String getUserId() {
    return userId.getStringValue();
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.