NotifyReply80.java :  » Client » android-gadu » pl » szpadel » android » gadu » packets » Android Open Source

Android Open Source » Client » android gadu 
android gadu » pl » szpadel » android » gadu » packets » NotifyReply80.java
package pl.szpadel.android.gadu.packets;

import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import pl.szpadel.android.gadu.Status;

/// Contact status notification
public class NotifyReply80 extends ReceivedPacket {

  /// Status info
  public static class StatusInfo {
    public long uin;
    public Status status;
  }
  
  /// Contact statuses contained by this packet
  public ArrayList<StatusInfo> statuses;
  
  /// C-tor
  public NotifyReply80(Header hdr, InputStream stream) throws IOException {
    super(hdr, stream);
  }

  /// C-tor
  protected NotifyReply80(Header hdr, ReadableByteChannel channel) throws IOException {
      super(hdr,channel);
  }

  @Override
  protected void readFromBuffer(ByteBuffer buffer) {
    statuses = new ArrayList<StatusInfo>();
    while (buffer.remaining() > 0) {
      StatusInfo si = new StatusInfo();
      
      si.uin = (long)(buffer.getInt());
      int s = buffer.getInt();
      
      buffer.getInt(); // features, ignored
      buffer.getInt(); // remote_ip, ignored
      buffer.getShort(); // remote_port, ignored
      buffer.get(); // image size, ignored
      buffer.get(); // unknown, ignored
      buffer.getInt(); // flags, ignored
      
      String statusDescription = getString(buffer);
      
      si.status = new Status(s, statusDescription);
      
      statuses.add(si);
    }
  }
  
  // To string
  public String toString() {
    String res = "Notify80 [ ";
    for(StatusInfo si : statuses ){
      res += "\n    (" + si.uin + "," + si.status + ")";
    }
    
    return res + " ]";
  }

}
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.