/*
*
* Hamsam - Instant Messaging API
*
* Copyright (C) 2003 Mike Miller <mikemil@users.sourceforge.net>
*
* 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 hamsam.protocol.aim.command;
import java.io.IOException;
import java.io.OutputStream;
import hamsam.protocol.aim.flap.*;
import hamsam.protocol.aim.util.ByteUtils;
import hamsam.protocol.aim.util.TLV;
import hamsam.protocol.aim.util.TLVConstants;
/**
* @author mikem
*/
public class LoginCmd extends Command {
public static final String VERSION = "$Id: LoginCmd.java,v 1.1 2003/07/23 03:15:55 mikemil Exp $";
private static final byte[] ID_NUMBER = { 0x00, 0x00, 0x00, 0x01 };
private static final byte[] MAJOR_VER = { 0x00, 0x01 };
private static final byte[] MINOR_VER = MAJOR_VER;
public LoginCmd(String screenName, String password) {
flapHdr = new FlapHeader(FlapConstants.FLAP_CHANNEL_CONNECT, 1);
addTLV( new TLV(TLVConstants.TLV_TYPE_SCREEN_NAME, screenName) );
addTLV( new TLV(TLVConstants.TLV_TYPE_ROASTED_PASSWORD, ByteUtils.roast(password)) );
addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_ID_STRING, "HAMSAM Test Client"));
addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_ID, MAJOR_VER));
addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_MAJOR_VERSION, MAJOR_VER));
addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_MINOR_VERSION, MINOR_VER));
addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_LESSOR_VERSION, MINOR_VER));
addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_BUILD_NUMBER, MINOR_VER));
addTLV( new TLV(TLVConstants.TLV_TYPE_DISTRIBUTION_NUMBER, ID_NUMBER));
addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_LANGUAGE, "en"));
addTLV( new TLV(TLVConstants.TLV_TYPE_CLIENT_COUNTRY, "us"));
}
// /* (non-Javadoc)
// * @see hamsam.protocol.aim.Command#getBytes()
// */
// public byte[] getBytes() {
// byte[] bytes = new byte[10];
// byte[] hdrBytes = flapHdr.getBytes();
// System.arraycopy(hdrBytes, 0, bytes, 0, FlapHeader.FLAP_HDR_LENGTH);
// System.arraycopy(ID_NUMBER, 0, bytes, FlapHeader.FLAP_HDR_LENGTH, ID_NUMBER.length);
// return bytes;
// }
//
/**
* Write the command data to the output stream (not including the FlapHeader or TLVs)
* @see hamsam.protocol.aim.command.Command#writeCommandData(java.io.OutputStream)
*/
public void writeCommandData(OutputStream os) throws IOException {
os.write(ID_NUMBER);
}
}