update source for tizen_2.1
[sdk/emulator/qemu.git] / tizen / src / skin / client / src / org / tizen / emulator / skin / comm / ICommunicator.java
1 /**
2  * 
3  *
4  * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  * GiWoong Kim <giwoong.kim@samsung.com>
8  * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
9  * HyunJun Son
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24  *
25  * Contributors:
26  * - S-Core Co., Ltd
27  *
28  */
29
30 package org.tizen.emulator.skin.comm;
31
32 import org.tizen.emulator.skin.comm.sock.data.ISendData;
33 import org.tizen.emulator.skin.dbi.RotationNameType;
34
35 /**
36  * 
37  *
38  */
39 public interface ICommunicator extends Runnable {
40
41         public enum Scale {
42                 SCALE_25(25),
43                 SCALE_50(50),
44                 SCALE_75(75),
45                 SCALE_100(100);
46
47                 private int value;
48
49                 Scale( int value ) {
50                         this.value = value;
51                 }
52
53                 public int value() {
54                         return this.value;
55                 }
56         }
57         
58         public enum MouseButtonType {
59                 LEFT( (short)1 ),
60                 WHEEL( (short)2 ),
61                 RIGHT( (short)3 );
62
63                 private short value;
64                 MouseButtonType( short value ) {
65                         this.value = value;
66                 }
67
68                 public short value() {
69                         return this.value;
70                 }
71
72                 public static MouseButtonType getValue( String val ) {
73                         MouseButtonType[] values = MouseButtonType.values();
74                         for (int i = 0; i < values.length; i++) {
75                                 if( values[i].value == Integer.parseInt( val ) ) {
76                                         return values[i];
77                                 }
78                         }
79                         throw new IllegalArgumentException( val );
80                 }
81
82                 public static MouseButtonType getValue( short val ) {
83                         MouseButtonType[] values = MouseButtonType.values();
84                         for (int i = 0; i < values.length; i++) {
85                                 if( values[i].value == val ) {
86                                         return values[i];
87                                 }
88                         }
89                         throw new IllegalArgumentException( Integer.toString(val) );
90                 }
91
92         }
93
94         public enum MouseEventType {
95                 PRESS( (short)1 ),
96                 RELEASE( (short)2 ),
97                 DRAG( (short)3 ),
98                 WHEELUP( (short)4 ),
99                 WHEELDOWN( (short)5 );
100
101                 private short value;
102                 MouseEventType( short value ) {
103                         this.value = value;
104                 }
105
106                 public short value() {
107                         return this.value;
108                 }
109
110                 public static MouseEventType getValue( String val ) {
111                         MouseEventType[] values = MouseEventType.values();
112                         for (int i = 0; i < values.length; i++) {
113                                 if( values[i].value == Integer.parseInt( val ) ) {
114                                         return values[i];
115                                 }
116                         }
117                         throw new IllegalArgumentException( val );
118                 }
119
120                 public static MouseEventType getValue( short val ) {
121                         MouseEventType[] values = MouseEventType.values();
122                         for (int i = 0; i < values.length; i++) {
123                                 if( values[i].value == val ) {
124                                         return values[i];
125                                 }
126                         }
127                         throw new IllegalArgumentException( Integer.toString(val) );
128                 }
129
130         }
131
132         public enum KeyEventType {
133                 PRESSED( (short)1 ),
134                 RELEASED( (short)2 );
135                 
136                 private short value;
137                 KeyEventType( short value ) {
138                         this.value = value;
139                 }
140
141                 public short value() {
142                         return this.value;
143                 }
144
145                 public static KeyEventType getValue( String val ) {
146                         KeyEventType[] values = KeyEventType.values();
147                         for (int i = 0; i < values.length; i++) {
148                                 if( values[i].value == Integer.parseInt( val ) ) {
149                                         return values[i];
150                                 }
151                         }
152                         throw new IllegalArgumentException( val );
153                 }
154
155                 public static KeyEventType getValue( short val ) {
156                         KeyEventType[] values = KeyEventType.values();
157                         for (int i = 0; i < values.length; i++) {
158                                 if( values[i].value == val ) {
159                                         return values[i];
160                                 }
161                         }
162                         throw new IllegalArgumentException( Integer.toString(val) );
163                 }
164
165         }
166
167         public enum RotationInfo {
168
169                 PORTRAIT( RotationNameType.PORTRAIT.value(), (short)0, 0 ),
170                 LANDSCAPE( RotationNameType.LANDSCAPE.value(), (short)1, -90 ),
171                 REVERSE_PORTRAIT( RotationNameType.REVERSE_PORTRAIT.value(), (short)2, 180 ),
172                 REVERSE_LANDSCAPE( RotationNameType.REVERSE_LANDSCAPE.value(), (short)3, 90 );
173                 
174                 private String value;
175                 private short id;
176                 private int angle;
177                 
178                 RotationInfo( String value, short id, int ratio ) {
179                         this.value = value;
180                         this.id = id;
181                         this.angle = ratio;
182                 }
183
184                 public String value() {
185                         return this.value;
186                 }
187
188                 public int angle() {
189                         return this.angle;
190                 }
191
192                 public short id() {
193                         return this.id;
194                 }
195                 
196                 public static RotationInfo getValue( short id ) {
197                         RotationInfo[] values = RotationInfo.values();
198                         for (int i = 0; i < values.length; i++) {
199                                 if( values[i].id == id ) {
200                                         return values[i];
201                                 }
202                         }
203                         throw new IllegalArgumentException( Integer.toString(id) );
204                 }
205
206         }
207
208         public enum SendCommand {
209                 /* This values must match the QEMU definitions */
210
211                 SEND_START( (short)1 ),
212                 
213                 SEND_MOUSE_EVENT( (short)10 ),
214                 SEND_KEY_EVENT( (short)11 ),
215                 SEND_HARD_KEY_EVENT( (short)12 ),
216                 CHANGE_LCD_STATE( (short)13 ),
217                 OPEN_SHELL( (short)14 ),
218                 HOST_KBD( (short)15 ),
219                 SCREEN_SHOT( (short)16 ),
220                 DETAIL_INFO( (short)17 ),
221                 RAM_DUMP( (short)18 ),
222                 GUEST_DUMP( (short)19 ),
223                 
224                 RESPONSE_HEART_BEAT( (short)900 ),
225                 CLOSE( (short)998 ),
226                 RESPONSE_SHUTDOWN( (short)999 );
227                 
228                 private short value;
229                 SendCommand( short value ) {
230                         this.value = value;
231                 }
232
233                 public short value() {
234                         return this.value;
235                 }
236
237                 public static SendCommand getValue( String val ) {
238                         SendCommand[] values = SendCommand.values();
239                         for (int i = 0; i < values.length; i++) {
240                                 if( values[i].value == Short.parseShort( val ) ) {
241                                         return values[i];
242                                 }
243                         }
244                         throw new IllegalArgumentException( val );
245                 }
246
247                 public static SendCommand getValue( short val ) {
248                         SendCommand[] values = SendCommand.values();
249                         for (int i = 0; i < values.length; i++) {
250                                 if( values[i].value == val ) {
251                                         return values[i];
252                                 }
253                         }
254                         throw new IllegalArgumentException( Integer.toString(val) );
255                 }
256         }
257
258         public enum ReceiveCommand {
259                 /* This values must match the QEMU definitions */
260
261                 HEART_BEAT((short) 1),
262                 SCREEN_SHOT_DATA((short) 2),
263                 DETAIL_INFO_DATA((short) 3),
264                 RAMDUMP_COMPLETE((short) 4),
265                 BOOTING_PROGRESS((short) 5),
266                 BRIGHTNESS_VALUE((short) 6),
267                 SENSOR_DAEMON_START((short) 800),
268                 SHUTDOWN((short) 999);
269
270                 private short value;
271                 ReceiveCommand( short value ) {
272                         this.value = value;
273                 }
274
275                 public short value() {
276                         return this.value;
277                 }
278
279                 public static ReceiveCommand getValue( String val ) {
280                         ReceiveCommand[] values = ReceiveCommand.values();
281                         for (int i = 0; i < values.length; i++) {
282                                 if( values[i].value == Short.parseShort( val ) ) {
283                                         return values[i];
284                                 }
285                         }
286                         throw new IllegalArgumentException( val );
287                 }
288
289                 public static ReceiveCommand getValue( short val ) {
290                         ReceiveCommand[] values = ReceiveCommand.values();
291                         for (int i = 0; i < values.length; i++) {
292                                 if( values[i].value == val ) {
293                                         return values[i];
294                                 }
295                         }
296                         throw new IllegalArgumentException( Integer.toString(val) );
297                 }
298         }
299
300         public void sendToQEMU( SendCommand command, ISendData data );
301         
302         public void terminate();
303         
304 }