|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 */ |
|
16 #include "HtiScreenshotH.h" |
|
17 |
|
18 #include "hticommon.h" |
|
19 #include "HtiPlugin.h" |
|
20 #include <string.h> |
|
21 |
|
22 #include "HtiSoapHandlerInterface.h" |
|
23 |
|
24 // Command codes |
|
25 const unsigned char CMD_SCR_FULL = 0x01; |
|
26 const unsigned char CMD_SCR_REGION = 0x02; |
|
27 const unsigned char CMD_SCR_FULL_ZIP = 0x03; |
|
28 const unsigned char CMD_SCR_REGION_ZIP = 0x04; |
|
29 |
|
30 const unsigned char CMD_TEXT_RCG_U = 0x11; |
|
31 const unsigned char CMD_TEXT_IMG_U = 0x13; |
|
32 |
|
33 const unsigned char CMD_SCR_FULL_SERIES = 0x21; |
|
34 const unsigned char CMD_SCR_REGION_SERIES = 0x22; |
|
35 const unsigned char CMD_SCR_FULL_ZIP_SERIES = 0x23; |
|
36 const unsigned char CMD_SCR_REGION_ZIP_SERIES = 0x24; |
|
37 |
|
38 const unsigned char CMD_CHANGE_SCREEN = 0x30; |
|
39 |
|
40 const unsigned char CMD_SCREEN_MODE = 0x3A; |
|
41 |
|
42 const unsigned char CMD_DELTA_SCR_FULL = 0x81; |
|
43 const unsigned char CMD_DELTA_SCR_REGION = 0x82; |
|
44 const unsigned char CMD_DELTA_SCR_FULL_ZIP = 0x83; |
|
45 const unsigned char CMD_DELTA_SCR_REGION_ZIP = 0x84; |
|
46 const unsigned char CMD_DELTA_SCR_RESET = 0x85; |
|
47 const unsigned char CMD_DELTA_SCR_FULL_SERIES = 0xA1; |
|
48 const unsigned char CMD_DELTA_SCR_REGION_SERIES = 0xA2; |
|
49 const unsigned char CMD_DELTA_SCR_FULL_ZIP_SERIES = 0xA3; |
|
50 const unsigned char CMD_DELTA_SCR_REGION_ZIP_SERIES = 0xA4; |
|
51 |
|
52 |
|
53 const unsigned char HTI_FONT_BOLD = 0x01; |
|
54 const unsigned char HTI_FONT_ITALIC = 0x02; |
|
55 const unsigned char HTI_FONT_NOTAA = 0x04; |
|
56 const unsigned char HTI_FONT_SUPER = 0x08; |
|
57 const unsigned char HTI_FONT_SUB = 0x18; |
|
58 |
|
59 const unsigned char TXT_RCG_OK = 0xF0; |
|
60 const unsigned char TXT_RCG_NOK = 0xF1; |
|
61 |
|
62 const int MAX_HREF_LEN = 128; |
|
63 |
|
64 char zipMimeType[] = "application/octet-stream"; //?? |
|
65 |
|
66 const static int g_ScreenHtiTimeoutImage = 120000; |
|
67 const static int g_ScreenHtiTimeoutRecongition = 60000; |
|
68 |
|
69 //********************************************************************************** |
|
70 // HELPER FUNCTIONS |
|
71 // |
|
72 //********************************************************************************** |
|
73 //********************************************************************************** |
|
74 // AddHtiFont |
|
75 //********************************************************************************** |
|
76 void AddHtiFont(HtiMsgHelper &msg, struct ns1__HtiFont &font) |
|
77 { |
|
78 msg.AddWCStringWithLengthByte( font.fontName ); |
|
79 msg.AddWord( font.fontHeight ); |
|
80 |
|
81 BYTE fontStyle = 0x0; |
|
82 |
|
83 // These can be combined |
|
84 if( font.isBold ) |
|
85 fontStyle |= HTI_FONT_BOLD; |
|
86 if( font.isItalic ) |
|
87 fontStyle |= HTI_FONT_ITALIC; |
|
88 if( font.isNotAntialiased ) |
|
89 fontStyle |= HTI_FONT_NOTAA; |
|
90 |
|
91 // And these cannot |
|
92 if( font.position == 1 ) |
|
93 fontStyle |= HTI_FONT_SUPER; |
|
94 else if( font.position == 2 ) |
|
95 fontStyle |= HTI_FONT_SUB; |
|
96 |
|
97 msg.AddByte( fontStyle ); |
|
98 } |
|
99 |
|
100 //********************************************************************************** |
|
101 // GetHref |
|
102 //********************************************************************************** |
|
103 void GetHref(char* str, const unsigned char cmd) |
|
104 { |
|
105 sprintf(str, "htiSs%x%d", cmd, clock() ); |
|
106 } |
|
107 |
|
108 //********************************************************************************** |
|
109 // SetScreenCaptureAttachment |
|
110 //********************************************************************************** |
|
111 int SetScreenCaptureAttachment(struct soap* soap, |
|
112 BYTE* data, |
|
113 int dataSize, |
|
114 BYTE command, |
|
115 char* mimeType, |
|
116 struct ns1__captureScreenResponse &r) |
|
117 { |
|
118 // alloc soap memory for attachment |
|
119 char* soapAttachment = (char*)soap_malloc(soap, dataSize ); |
|
120 memcpy( soapAttachment, data, dataSize ); |
|
121 |
|
122 // get & set href for attachment |
|
123 char href[MAX_HREF_LEN]; |
|
124 GetHref(href, command); |
|
125 r._returnAttachment.href = (char*)soap_malloc(soap, strlen(href)+1 ); |
|
126 strcpy( r._returnAttachment.href, href ); |
|
127 |
|
128 // default mimetype is bmp |
|
129 if ( !( mimeType ? strlen( mimeType ) : 0 ) ) |
|
130 mimeType = "image/bmp"; |
|
131 |
|
132 // set mimetype |
|
133 r._returnAttachment.mimeType = (char*)soap_malloc(soap, strlen(mimeType)+1 ); |
|
134 strcpy( r._returnAttachment.mimeType, mimeType ); |
|
135 |
|
136 // set the attahcment |
|
137 soap_set_dime(soap); |
|
138 return soap_set_dime_attachment(soap, soapAttachment, dataSize, |
|
139 mimeType, href, 0, NULL); |
|
140 } |
|
141 |
|
142 //********************************************************************************** |
|
143 // SetDeltaScreenCaptureAttachment |
|
144 //********************************************************************************** |
|
145 int SetDeltaScreenCaptureAttachment(struct soap* soap, |
|
146 BYTE* data, |
|
147 int dataSize, |
|
148 BYTE command, |
|
149 char* mimeType, |
|
150 struct ns1__captureDeltaScreenResponse &r) |
|
151 { |
|
152 // Set rectangle |
|
153 r._returnDeltaAttachment.rect.topLeftX = *(WORD*)data; data+=2; |
|
154 r._returnDeltaAttachment.rect.topLeftY = *(WORD*)data; data+=2; |
|
155 r._returnDeltaAttachment.rect.bottomRightX = *(WORD*)data; data+=2; |
|
156 r._returnDeltaAttachment.rect.bottomRightY = *(WORD*)data; data+=2; |
|
157 dataSize -= 2*4; |
|
158 |
|
159 // No attachment? |
|
160 if ( dataSize == 0 ) |
|
161 return SOAP_OK; |
|
162 |
|
163 // alloc soap memory for attachment |
|
164 char* soapAttachment = (char*)soap_malloc(soap, dataSize ); |
|
165 memcpy( soapAttachment, data, dataSize ); |
|
166 |
|
167 // get & set href for attachment |
|
168 char href[MAX_HREF_LEN]; |
|
169 GetHref(href, command); |
|
170 r._returnDeltaAttachment.href = (char*)soap_malloc(soap, strlen(href)+1 ); |
|
171 strcpy( r._returnDeltaAttachment.href, href ); |
|
172 |
|
173 // default mimetype is bmp |
|
174 if ( !( mimeType ? strlen( mimeType ) : 0 ) ) |
|
175 mimeType = "image/bmp"; |
|
176 |
|
177 // set mimetype |
|
178 r._returnDeltaAttachment.mimeType = (char*)soap_malloc(soap, strlen(mimeType)+1 ); |
|
179 strcpy( r._returnDeltaAttachment.mimeType, mimeType ); |
|
180 |
|
181 // set the attahcment |
|
182 soap_set_dime(soap); |
|
183 return soap_set_dime_attachment(soap, soapAttachment, dataSize, |
|
184 mimeType, href, 0, NULL); |
|
185 } |
|
186 |
|
187 //********************************************************************************** |
|
188 // GetSerieShotFiles |
|
189 //********************************************************************************** |
|
190 int GetSerieShotFiles(struct soap* soap, |
|
191 HtiMsgHelper &msg, |
|
192 struct ArrayOfFiles *files ) |
|
193 { |
|
194 // list of screenshot files is returned |
|
195 char** tmp_array_ptr = NULL; |
|
196 int i = 0; |
|
197 files->__size = 0; |
|
198 while( i < msg.GetMsgLen() ) |
|
199 { |
|
200 int fileNameLen = msg.GetMsgBody()[i++]; |
|
201 tmp_array_ptr = (char**) realloc(tmp_array_ptr, |
|
202 (files->__size+1)*sizeof(char**)); |
|
203 tmp_array_ptr[files->__size++] = msg.GetSoapString( i, fileNameLen ); |
|
204 i += fileNameLen; |
|
205 } |
|
206 |
|
207 if ( files->__size == 0 ) |
|
208 { |
|
209 soap->error = soap_receiver_fault( soap, "HtiError", |
|
210 "No screenshot files returned"); |
|
211 return SOAP_FAULT; |
|
212 } |
|
213 |
|
214 // alloc (soap) space for pointers & copy data from tmp_array_ptr |
|
215 files->__ptr = (char**) soap_malloc(soap, sizeof(char**)*files->__size); |
|
216 memcpy(files->__ptr, tmp_array_ptr, sizeof(char**)*files->__size); |
|
217 free(tmp_array_ptr); |
|
218 return SOAP_OK; |
|
219 } |
|
220 |
|
221 //********************************************************************************** |
|
222 // SOAP FUNCTIONS |
|
223 // |
|
224 //********************************************************************************** |
|
225 |
|
226 //********************************************************************************** |
|
227 // ns1__captureFullScreen |
|
228 //********************************************************************************** |
|
229 int ns1__captureFullScreen(struct soap* soap, |
|
230 unsigned char colorDepth, |
|
231 char *imageMimeType, |
|
232 struct ns1__captureScreenResponse &r) |
|
233 { |
|
234 HtiMsgHelper msg( soap, HTI_UID, CMD_SCR_FULL ); |
|
235 msg.AddByte( colorDepth ); |
|
236 msg.AddString( imageMimeType ); |
|
237 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) ) |
|
238 return SOAP_FAULT; |
|
239 |
|
240 return SetScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(), |
|
241 CMD_SCR_FULL, imageMimeType ,r ); |
|
242 } |
|
243 |
|
244 //********************************************************************************** |
|
245 // ns1__captureFullScreenZip |
|
246 //********************************************************************************** |
|
247 int ns1__captureFullScreenZip(struct soap* soap, |
|
248 unsigned char colorDepth, |
|
249 char *imageMimeType, |
|
250 struct ns1__captureScreenResponse &r) |
|
251 { |
|
252 HtiMsgHelper msg( soap, HTI_UID, CMD_SCR_FULL_ZIP ); |
|
253 msg.AddByte( colorDepth ); |
|
254 msg.AddString( imageMimeType ); |
|
255 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) ) |
|
256 return SOAP_FAULT; |
|
257 |
|
258 return SetScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(), |
|
259 CMD_SCR_FULL_ZIP, zipMimeType ,r ); |
|
260 } |
|
261 |
|
262 //********************************************************************************** |
|
263 // ns1__captureRegion |
|
264 //********************************************************************************** |
|
265 int ns1__captureRegion(struct soap* soap, |
|
266 struct ns1__HtiRect rect, |
|
267 unsigned char colorDepth, |
|
268 char *imageMimeType, |
|
269 struct ns1__captureScreenResponse &r) |
|
270 { |
|
271 HtiMsgHelper msg( soap, HTI_UID, CMD_SCR_REGION ); |
|
272 msg.AddWord( rect.topLeftX ); |
|
273 msg.AddWord( rect.topLeftY ); |
|
274 msg.AddWord( rect.bottomRightX ); |
|
275 msg.AddWord( rect.bottomRightY ); |
|
276 msg.AddByte( colorDepth ); |
|
277 msg.AddString( imageMimeType ); |
|
278 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) ) |
|
279 return SOAP_FAULT; |
|
280 |
|
281 return SetScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(), |
|
282 CMD_SCR_REGION, imageMimeType ,r ); |
|
283 } |
|
284 |
|
285 //********************************************************************************** |
|
286 // ns1__captureRegionZip |
|
287 //********************************************************************************** |
|
288 int ns1__captureRegionZip(struct soap* soap, |
|
289 struct ns1__HtiRect rect, |
|
290 unsigned char colorDepth, |
|
291 char *imageMimeType, |
|
292 struct ns1__captureScreenResponse &r) |
|
293 { |
|
294 HtiMsgHelper msg( soap, HTI_UID, CMD_SCR_REGION_ZIP ); |
|
295 msg.AddWord( rect.topLeftX ); |
|
296 msg.AddWord( rect.topLeftY ); |
|
297 msg.AddWord( rect.bottomRightX ); |
|
298 msg.AddWord( rect.bottomRightY ); |
|
299 msg.AddByte( colorDepth ); |
|
300 msg.AddString( imageMimeType ); |
|
301 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) ) |
|
302 return SOAP_FAULT; |
|
303 |
|
304 return SetScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(), |
|
305 CMD_SCR_REGION_ZIP, zipMimeType ,r ); |
|
306 } |
|
307 |
|
308 //********************************************************************************** |
|
309 // ns1__recognizeText |
|
310 //********************************************************************************** |
|
311 int ns1__recognizeText(struct soap* soap, |
|
312 wchar_t *text, |
|
313 struct ArrayOfHtiFonts* array, |
|
314 struct ns1__recognizeTextResponse &r) |
|
315 { |
|
316 // check text parameter |
|
317 if ( check_mandatory_wcstring_parameter( soap, text, "text" ) ) |
|
318 return SOAP_FAULT; |
|
319 else if ( wcslen( text ) > 0xff ) |
|
320 { |
|
321 soap->error = soap_sender_fault(soap, "HtiGateway", "Text too long"); |
|
322 return SOAP_FAULT; |
|
323 } |
|
324 |
|
325 // check array parameter |
|
326 if ( array == NULL ) |
|
327 { |
|
328 soap->error = soap_sender_fault( soap, "HtiGateway", |
|
329 "No font array parameter" ); |
|
330 return SOAP_FAULT; |
|
331 } |
|
332 else if ( array->__size < 0 ) |
|
333 { |
|
334 soap->error = soap_sender_fault( soap, "HtiGateway", "Font array empty" ); |
|
335 return SOAP_FAULT; |
|
336 } |
|
337 else if ( array->__size > 0xff ) |
|
338 { |
|
339 soap->error = soap_sender_fault( soap, "HtiGateway", "Too many fonts" ); |
|
340 return SOAP_FAULT; |
|
341 } |
|
342 for ( int i = 0; i < array->__size; i++ ) |
|
343 { |
|
344 char tmp[20]; |
|
345 sprintf(tmp, "HtiFont[%d]", i); |
|
346 if ( check_mandatory_wcstring_parameter( soap, |
|
347 array->__ptrHtiFont[i].fontName, tmp ) ) |
|
348 return SOAP_FAULT; |
|
349 } |
|
350 |
|
351 // construct and send the message |
|
352 HtiMsgHelper msg( soap, HTI_UID, CMD_TEXT_RCG_U ); |
|
353 msg.AddWCStringWithLengthByte( text ); |
|
354 msg.AddByte( array->__size ); |
|
355 for( int i = 0; i < array->__size; i++ ) |
|
356 AddHtiFont( msg, array->__ptrHtiFont[i] ); |
|
357 |
|
358 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutRecongition ) ) |
|
359 return SOAP_FAULT; |
|
360 |
|
361 // Check response |
|
362 if ( msg.CheckMsgExactLen( 6 ) ) |
|
363 return SOAP_FAULT; |
|
364 |
|
365 switch( msg.GetByte(0) ) |
|
366 { |
|
367 case TXT_RCG_OK: |
|
368 r._returnText.found = true; |
|
369 r._returnText.x = msg.GetWord( 1 ); |
|
370 r._returnText.y = msg.GetWord( 3 ); |
|
371 r._returnText.fontIndex = msg.GetByte( 5 ); |
|
372 break; |
|
373 |
|
374 case TXT_RCG_NOK: |
|
375 r._returnText.found = false; |
|
376 break; |
|
377 |
|
378 default: |
|
379 soap->error = soap_receiver_fault_format(soap, "HtiError", |
|
380 "Invalid response command code 0x%x", msg.GetByte(0) ); |
|
381 return SOAP_FAULT; |
|
382 } |
|
383 |
|
384 return SOAP_OK; |
|
385 } |
|
386 |
|
387 //********************************************************************************** |
|
388 // ns1__createTextImage |
|
389 //********************************************************************************** |
|
390 int ns1__createTextImage(struct soap* soap, |
|
391 unsigned char colorDepth, |
|
392 char *imageMimeType, |
|
393 wchar_t *text, |
|
394 struct ns1__HtiFont* font, |
|
395 struct ns1__HtiRGB fgColor, |
|
396 struct ns1__HtiRGB bgColor, |
|
397 struct ns1__captureScreenResponse &r) |
|
398 { |
|
399 // check text & imageMimeType parameters |
|
400 if ( check_mandatory_wcstring_parameter( soap, text, "text" ) || |
|
401 check_mandatory_string_parameter( soap, imageMimeType, "imageMimeType" ) ) |
|
402 return SOAP_FAULT; |
|
403 else if ( wcslen( text ) > 0xff ) |
|
404 { |
|
405 soap->error = soap_sender_fault(soap, "HtiGateway", "Text too long"); |
|
406 return SOAP_FAULT; |
|
407 } |
|
408 |
|
409 // check font parameter |
|
410 if ( font == NULL ) |
|
411 { |
|
412 soap->error = soap_sender_fault( soap, "HtiGateway", "No font parameter" ); |
|
413 return SOAP_FAULT; |
|
414 } |
|
415 if ( check_mandatory_wcstring_parameter( soap, font->fontName, "fontName" ) ) |
|
416 return SOAP_FAULT; |
|
417 |
|
418 // construct and send the message |
|
419 HtiMsgHelper msg( soap, HTI_UID, CMD_TEXT_IMG_U ); |
|
420 msg.AddByte( colorDepth ); |
|
421 msg.AddStringWithLengthByte( imageMimeType ); |
|
422 msg.AddWCStringWithLengthByte( text ); |
|
423 AddHtiFont( msg, *font ); |
|
424 msg.AddByte( fgColor.red ); // note little endian encoding |
|
425 msg.AddByte( fgColor.green ); |
|
426 msg.AddByte( fgColor.blue ); |
|
427 msg.AddByte( 0x00 ); |
|
428 msg.AddByte( bgColor.red ); |
|
429 msg.AddByte( bgColor.green ); |
|
430 msg.AddByte( bgColor.blue ); |
|
431 msg.AddByte( 0x00 ); |
|
432 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) ) |
|
433 return SOAP_FAULT; |
|
434 |
|
435 // get response |
|
436 return SetScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(), |
|
437 CMD_TEXT_IMG_U, imageMimeType ,r ); |
|
438 } |
|
439 |
|
440 |
|
441 |
|
442 //********************************************************************************** |
|
443 // ns1__captureFullScreenSeries |
|
444 //********************************************************************************** |
|
445 int ns1__captureFullScreenSeries(struct soap* soap, |
|
446 int duration, |
|
447 int interval, |
|
448 unsigned char colorDepth, |
|
449 char *imageMimeType, |
|
450 struct ArrayOfFiles *files) |
|
451 { |
|
452 HtiMsgHelper msg( soap, HTI_UID, CMD_SCR_FULL_SERIES ); |
|
453 msg.AddInt( duration ); |
|
454 msg.AddInt( interval ); |
|
455 msg.AddByte( colorDepth ); |
|
456 msg.AddString( imageMimeType ); |
|
457 int timeout = HTIMSG_TIMEOUT_10_SECONDS + duration/1000; // duration is in us |
|
458 if ( msg.SendReceiveMsg( timeout ) ) |
|
459 return SOAP_FAULT; |
|
460 |
|
461 return GetSerieShotFiles( soap, msg, files ); |
|
462 } |
|
463 |
|
464 //********************************************************************************** |
|
465 // ns1__captureFullScreenZipSeries |
|
466 //********************************************************************************** |
|
467 int ns1__captureFullScreenZipSeries(struct soap* soap, |
|
468 int duration, |
|
469 int interval, |
|
470 unsigned char colorDepth, |
|
471 char *imageMimeType, |
|
472 struct ArrayOfFiles *files) |
|
473 { |
|
474 HtiMsgHelper msg( soap, HTI_UID, CMD_SCR_FULL_ZIP_SERIES ); |
|
475 msg.AddInt( duration ); |
|
476 msg.AddInt( interval ); |
|
477 msg.AddByte( colorDepth ); |
|
478 msg.AddString( imageMimeType ); |
|
479 int timeout = HTIMSG_TIMEOUT_10_SECONDS + duration/1000; // duration is in us |
|
480 if ( msg.SendReceiveMsg( timeout ) ) |
|
481 return SOAP_FAULT; |
|
482 |
|
483 return GetSerieShotFiles( soap, msg, files ); |
|
484 } |
|
485 |
|
486 //********************************************************************************** |
|
487 // ns1__captureRegionSeries |
|
488 //********************************************************************************** |
|
489 int ns1__captureRegionSeries(struct soap* soap, |
|
490 int duration, |
|
491 int interval, |
|
492 unsigned char colorDepth, |
|
493 struct ns1__HtiRect rect, |
|
494 char *imageMimeType, |
|
495 struct ArrayOfFiles *files) |
|
496 { |
|
497 HtiMsgHelper msg( soap, HTI_UID, CMD_SCR_REGION_SERIES ); |
|
498 msg.AddInt( duration ); |
|
499 msg.AddInt( interval ); |
|
500 msg.AddByte( colorDepth ); |
|
501 msg.AddWord( rect.topLeftX ); |
|
502 msg.AddWord( rect.topLeftY ); |
|
503 msg.AddWord( rect.bottomRightX ); |
|
504 msg.AddWord( rect.bottomRightY ); |
|
505 msg.AddString( imageMimeType ); |
|
506 int timeout = HTIMSG_TIMEOUT_10_SECONDS + duration/1000; // duration is in us |
|
507 if ( msg.SendReceiveMsg( timeout ) ) |
|
508 return SOAP_FAULT; |
|
509 |
|
510 return GetSerieShotFiles( soap, msg, files ); |
|
511 } |
|
512 |
|
513 //********************************************************************************** |
|
514 // ns1__captureRegionZipSeries |
|
515 //********************************************************************************** |
|
516 int ns1__captureRegionZipSeries(struct soap* soap, |
|
517 int duration, |
|
518 int interval, |
|
519 unsigned char colorDepth, |
|
520 struct ns1__HtiRect rect, |
|
521 char *imageMimeType, |
|
522 struct ArrayOfFiles *files) |
|
523 { |
|
524 HtiMsgHelper msg( soap, HTI_UID, CMD_SCR_REGION_ZIP_SERIES ); |
|
525 msg.AddInt( duration ); |
|
526 msg.AddInt( interval ); |
|
527 msg.AddByte( colorDepth ); |
|
528 msg.AddWord( rect.topLeftX ); |
|
529 msg.AddWord( rect.topLeftY ); |
|
530 msg.AddWord( rect.bottomRightX ); |
|
531 msg.AddWord( rect.bottomRightY ); |
|
532 msg.AddString( imageMimeType ); |
|
533 int timeout = HTIMSG_TIMEOUT_10_SECONDS + duration/1000; // duration is in us |
|
534 if ( msg.SendReceiveMsg( timeout ) ) |
|
535 return SOAP_FAULT; |
|
536 |
|
537 return GetSerieShotFiles( soap, msg, files ); |
|
538 } |
|
539 |
|
540 //********************************************************************************** |
|
541 // ns1__captureDeltaFullScreen |
|
542 //********************************************************************************** |
|
543 int ns1__captureDeltaFullScreen(struct soap* soap, |
|
544 unsigned char colorDepth, |
|
545 char *imageMimeType, |
|
546 struct ns1__captureDeltaScreenResponse &r) |
|
547 { |
|
548 HtiMsgHelper msg( soap, HTI_UID, CMD_DELTA_SCR_FULL ); |
|
549 msg.AddByte( colorDepth ); |
|
550 msg.AddString( imageMimeType ); |
|
551 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) ) |
|
552 return SOAP_FAULT; |
|
553 |
|
554 return SetDeltaScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(), |
|
555 CMD_DELTA_SCR_FULL, imageMimeType ,r ); |
|
556 } |
|
557 //********************************************************************************** |
|
558 // ns1__captureDeltaFullScreenZip |
|
559 //********************************************************************************** |
|
560 int ns1__captureDeltaFullScreenZip(struct soap* soap, |
|
561 unsigned char colorDepth, |
|
562 char *imageMimeType, |
|
563 struct ns1__captureDeltaScreenResponse &r) |
|
564 { |
|
565 HtiMsgHelper msg( soap, HTI_UID, CMD_DELTA_SCR_FULL_ZIP ); |
|
566 msg.AddByte( colorDepth ); |
|
567 msg.AddString( imageMimeType ); |
|
568 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) ) |
|
569 return SOAP_FAULT; |
|
570 |
|
571 return SetDeltaScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(), |
|
572 CMD_DELTA_SCR_FULL_ZIP, zipMimeType ,r ); |
|
573 } |
|
574 //********************************************************************************** |
|
575 // ns1__captureDeltaRegion |
|
576 //********************************************************************************** |
|
577 int ns1__captureDeltaRegion(struct soap* soap, |
|
578 struct ns1__HtiRect rect, |
|
579 unsigned char colorDepth, |
|
580 char *imageMimeType, |
|
581 struct ns1__captureDeltaScreenResponse &r) |
|
582 { |
|
583 HtiMsgHelper msg( soap, HTI_UID, CMD_DELTA_SCR_REGION ); |
|
584 msg.AddWord( rect.topLeftX ); |
|
585 msg.AddWord( rect.topLeftY ); |
|
586 msg.AddWord( rect.bottomRightX ); |
|
587 msg.AddWord( rect.bottomRightY ); |
|
588 msg.AddByte( colorDepth ); |
|
589 msg.AddString( imageMimeType ); |
|
590 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) ) |
|
591 return SOAP_FAULT; |
|
592 |
|
593 return SetDeltaScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(), |
|
594 CMD_DELTA_SCR_REGION, imageMimeType ,r ); |
|
595 } |
|
596 //********************************************************************************** |
|
597 // ns1__captureDeltaRegionZip |
|
598 //********************************************************************************** |
|
599 int ns1__captureDeltaRegionZip(struct soap* soap, |
|
600 struct ns1__HtiRect rect, |
|
601 unsigned char colorDepth, |
|
602 char *imageMimeType, |
|
603 struct ns1__captureDeltaScreenResponse &r) |
|
604 { |
|
605 HtiMsgHelper msg( soap, HTI_UID, CMD_DELTA_SCR_REGION_ZIP ); |
|
606 msg.AddWord( rect.topLeftX ); |
|
607 msg.AddWord( rect.topLeftY ); |
|
608 msg.AddWord( rect.bottomRightX ); |
|
609 msg.AddWord( rect.bottomRightY ); |
|
610 msg.AddByte( colorDepth ); |
|
611 msg.AddString( imageMimeType ); |
|
612 if ( msg.SendReceiveMsg( g_ScreenHtiTimeoutImage ) ) |
|
613 return SOAP_FAULT; |
|
614 |
|
615 return SetDeltaScreenCaptureAttachment( soap, msg.GetMsgBody(), msg.GetMsgLen(), |
|
616 CMD_DELTA_SCR_REGION_ZIP, zipMimeType ,r ); |
|
617 } |
|
618 |
|
619 //********************************************************************************** |
|
620 // ns1__selectScreen |
|
621 //********************************************************************************** |
|
622 int ns1__selectScreen(struct soap* soap, |
|
623 unsigned char screenNr, |
|
624 struct ns1__selectScreenResponse *out) |
|
625 { |
|
626 HtiMsgHelper msg( soap, HTI_UID, CMD_CHANGE_SCREEN ); |
|
627 msg.AddByte( screenNr ); |
|
628 return msg.SendReceiveMsg( HTIMSG_TIMEOUT_10_SECONDS ); |
|
629 } |
|
630 |
|
631 //********************************************************************************** |
|
632 // ns1__resetDeltaScreen |
|
633 //********************************************************************************** |
|
634 int ns1__resetDeltaScreen(struct soap* soap, |
|
635 void *_, |
|
636 struct ns1__resetDeltaScreenResponse *out) |
|
637 { |
|
638 HtiMsgHelper msg( soap, HTI_UID, CMD_DELTA_SCR_RESET ); |
|
639 return msg.SendReceiveMsg( HTIMSG_TIMEOUT_10_SECONDS ); |
|
640 } |
|
641 |
|
642 //********************************************************************************** |
|
643 // ns1__screenMode |
|
644 //********************************************************************************** |
|
645 int ns1__screenMode(struct soap* soap, |
|
646 void *_, |
|
647 struct ns1__screenModeResponse& r) |
|
648 { |
|
649 HtiMsgHelper msg( soap, HTI_UID, CMD_SCREEN_MODE ); |
|
650 if ( msg.SendReceiveMsg( HTIMSG_TIMEOUT_10_SECONDS ) ) |
|
651 return SOAP_FAULT; |
|
652 |
|
653 // Check response |
|
654 if ( msg.CheckMsgExactLen( 8 ) ) |
|
655 return SOAP_FAULT; |
|
656 |
|
657 r._returnScreenMode.screenNumber = msg.GetByte( 0 ); |
|
658 r._returnScreenMode.screenWidth = msg.GetWord( 1 ); |
|
659 r._returnScreenMode.screenHeight = msg.GetWord( 3 ); |
|
660 r._returnScreenMode.screenRotation = (ns1__screenOrientation)msg.GetByte( 5 ); |
|
661 r._returnScreenMode.displayMode = msg.GetByte( 6 ); |
|
662 r._returnScreenMode.focusScreenNumber = msg.GetByte( 7 ); |
|
663 |
|
664 return SOAP_OK; |
|
665 } |