Source code: com/wilko/jaim/FLAPSignonFrame.java
1 /*
2 * (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19
20 /*
21 * FlapSignonFrame.java
22 *
23 * Created on 3 May 2002, 14:54
24 */
25
26 package com.wilko.jaim;
27
28 /**
29 *
30 * @author paulw
31 * @version $Revision: 1.3 $
32 */
33 public class FLAPSignonFrame extends FLAPFrame {
34
35 /** Creates new FlapSignonFrame */
36 public FLAPSignonFrame() {
37 frame[1]=FLAP_FRAME_SIGNON;
38 }
39
40 public FLAPSignonFrame(byte frameData[])
41 {
42 frame[1]=FLAP_FRAME_SIGNON;
43 setFrameData(frameData);
44 }
45
46 public int getFLAPVersion()
47 {
48 return(((frame[6]&0xff)*16777216)+((frame[7]&0xff)*65536)+((frame[8]&0xff)*256)+(frame[9]&0xff));
49 }
50
51 public void setFLAPVersion(int version)
52 {
53 for (int i=3;i>=0;i--)
54 {
55 frame[6+i]=(byte)(version&0xff);
56 version=version>>8;
57 }
58 }
59
60 public void setTLVTag(int tag)
61 {
62 for (int i=1;i>=0;i--)
63 {
64 frame[10+i]=(byte)(tag&0xff);
65 tag=tag>>8;
66 }
67 }
68
69 public void setUserName(String name)
70 {
71
72 int len=0;
73 for (int i=0;i<name.length();i++)
74 {
75 char c = name.charAt(i);
76 if (c != ' ')
77 {
78 frame[FLAP_DATA_OFFSET+8+len++]=(byte)c;
79 }
80 }
81 setLength(8+len);
82 frame[FLAP_DATA_OFFSET+6]=(byte)(len/256);
83 frame[FLAP_DATA_OFFSET+7]=(byte)(len&0xff);
84 }
85
86 public int getFLAPFrameType() {
87 return(FLAPFrame.FLAP_FRAME_SIGNON);
88 }
89
90 }