comparison src/aci2/bmi/mmiFileViewer.c @ 120:3c2acfa1a72f

src/aci2/bmi: file renames to make filename case consistent
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 07 Oct 2016 03:46:05 +0000
parents src/aci2/bmi/MmiFileViewer.c@93999a60b835
children
comparison
equal deleted inserted replaced
119:b92a33c204b6 120:3c2acfa1a72f
1 /*******************************************************************************
2
3 Texas Instruments
4
5 ********************************************************************************
6
7 This software product is the property of Texas Instruments and may not be
8 disclosed to any third party without the express permission of the owner.
9
10 ********************************************************************************
11
12 $Project name: File Viewer
13 $Module: File Viewer
14 $File: MmiFileViewer.c
15 $Revision: 1.0
16 $Author: xdeepadh - sasken India
17 $Date: 11/05/05
18
19 ********************************************************************************
20
21 Description: This module contains the functionality of File Viewer Application.
22
23 ********************************************************************************
24 $History: MmiFileViewer.c
25 Jan 03, 2006 REF: SPR OMAPS00060036 xdeepadh
26 Description:In file viewer, the user is not allowed to retain the old name once he/she goes to the rename file option.
27 Solution:While renaming the file,if the name already exists, display a proper error message
28
29 Aug 31, 2005 REF: SPR 34050 xdeepadh
30 Description: The application hangs if while renaming a saved file a special character such as '?', '!' etc is used
31 Solution: Error message will be displayed when ffs_rename() fails
32
33 Aug 30, 2005 REF:SPR 34049 xdeepadh
34 Description: FileViewer: Not able to delete a file that is too big to display
35 Solution: When the file was too big to display, the file handle was closed.
36
37 Aug 22, 2005 REF: ENH 31154 xdeepadh
38 Description: Application to Test Camera
39 Solution: Implemeted the Fileviewer to view the jpeg images.Camera Application to
40 preview,capture and save image has been implemented.
41
42
43
44 $End
45
46 *******************************************************************************/
47
48 #define ENTITY_MFW
49
50 /* includes */
51
52 #include <string.h>
53 #include <stdio.h>
54 #include <stdlib.h>
55
56
57 #if defined (NEW_FRAME)
58 #include "typedefs.h"
59 #include "Vsi.h"
60 #include "PEI.H"
61 #include "custom.h"
62 #include "gsm.h"
63 #include "prim.h"
64
65 #else
66 #include "stddefs.h"
67 #include "custom.h"
68 #include "gsm.h"
69 #include "Vsi.h"
70
71 #endif
72
73 #include "message.h" /* included for aci_cmh.h .... */
74 #include "aci_cmh.h" /* included for mfw_sat.h, included for MmiDummy.h, included for MmiMenu.h */
75
76 #include "mfw_mfw.h"
77 #include "mfw_win.h"
78 #include "mfw_icn.h" /* included for mfw_mnu.h */
79 #include "mfw_mnu.h"
80 #include "mfw_tim.h"
81 #include "mfw_kbd.h"
82 #include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */
83 #include "mfw_fv.h" //Will be enabled once the IMGIL APIS are provided.
84
85
86 #include "ffs/ffs_api.h"
87
88 #include "MmiBlkLangDB.h"
89 #include "mmiColours.h"
90 #include "MmiDialogs.h"
91 #include "MmiDummy.h" /* included for MmiMenu.h */
92 #include "MmiLists.h"
93 #include "MmiMenu.h"
94 #include "MmiSoftKeys.h"
95 #include "AUIEditor.h"
96 #include "MmiFileViewer.h"
97 #include "MmiMain.h"
98 #include "Mmibookshared.h"
99
100 /*local defines*/
101
102 //Events for windows
103 #define FV_INIT 1
104 #define FV_RETURN 2
105 #define FV_ABORT 3
106 #define FV_EXIT 4
107
108 //Events for editor
109 #define FV_EDITOR_CANCEL 5
110 #define FV_EDITOR_SELECT 6
111 #define FV_EDITOR_ERROR 7 //Aug 31, 2005 REF: SPR 34050 xdeepadh
112
113 //Ids for diffrent functionalities.
114 #define FV_OPT_ID 100
115 #define FV_EDT_ID 101
116 #define FV_DEL_ID 102
117
118 #define FV_INFO_SCRN_TIMEOUT 1500
119 //Aug 31, 2005 REF: SPR 34050 xdeepadh
120 #define FV_FILE_NAME_LENGTH 20
121 #define FV_DIR_PATH_LENGTH (10 + FV_FILE_NAME_LENGTH)
122 #define FV_DIR_NAME "/mmi/jpeg/"
123 #define FV_MAX_NUM_FILES 10
124 #define FV_MAX_JPEG_SIZE (64 * 1024)
125
126
127 //Variable defines
128
129
130 UINT8 qcif_yuv_lum[FV_DSPL_VOLUME]; //decoded and Scaled lum buffer
131 UINT8 qcif_yuv_cb[FV_SCALE_VOLUME]; //decoded and Scaled cb buffer
132 UINT8 qcif_yuv_cr[FV_SCALE_VOLUME]; //decoded and Scaled cr buffer
133
134 UINT8 qcif_rgb_array[ FV_DSPL_VOLUME * 2]; //Color converted buffer to view
135 UINT8 rgb_img_process_array[FV_DSPL_VOLUME * 2]; //Color converted buffer for zoom/rotate
136
137 UINT8 qcif_yuv_process_lum[FV_DSPL_VOLUME ]; //lum buffer for rotate and zoom
138 UINT8 qcif_yuv_process_cb[FV_SCALE_VOLUME]; //cb buffer for rotate and zoom
139 UINT8 qcif_yuv_process_cr[FV_SCALE_VOLUME]; //cr buffer for rotate and zoom
140
141
142 /*menu data structure definition*/
143 typedef struct
144 {
145 T_MMI_CONTROL mmi_control;
146 T_MFW_HND win;
147 T_MFW_HND kbd;
148 T_MFW_HND kbd_long;
149 T_MFW_HND fv_menu;
150 T_MFW_HND fv_option_win;
151 T_MFW_HND parent;
152 ListMenuData fv_list_data;
153 UBYTE fv_file_count;
154 ListCbFunc fv_list_cb;
155 UBYTE fv_list_idx;
156
157 }T_fv_menu;
158
159 typedef struct
160 {
161 /* administrative data */
162 T_MMI_CONTROL mmi_control;
163 T_MFW_HND win;
164 SHORT id;
165 T_MFW_HND parent;
166 /* associated handlers */
167 T_MFW_HND kbd;
168 T_MFW_HND kbd_long;
169 T_MFW_HND menu;
170 T_fv_menu * parent_data;
171 } T_fv_opt;
172
173 /*editor data structure*/
174 typedef struct{
175 T_MMI_CONTROL mmi_control;
176 MfwHnd win;
177 MfwHnd fv_win_editor;
178 UBYTE fv_buffer[FV_FILE_NAME_LENGTH];
179 } T_FV_Editor_Data;
180
181
182 /*default static menu*/
183 static MfwMnuAttr menuFvSearchListAttr =
184 {
185 &menuArea,
186 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
187 -1, /* use default font */
188 NULL, /* with these items (filled in later) */
189 0, /* number of items (filled in leter) */
190 COLOUR_LIST_XX, /* Colour */
191 TxtNull, /* Hdr Id */
192 NULL, /* Background */
193 MNUATTRSPARE /* unused */
194 };
195
196 static const MfwMnuItem Mmi_fv_OPTItems [] =
197 {
198 {0,0,0,(char *)TxtView,0,(MenuFunc)mmi_fv_view_image_start,item_flag_none},
199 {0,0,0,(char *)TxtDelete,0,(MenuFunc)mmi_fv_delete_start,item_flag_none},
200 {0,0,0,(char *)TxtRename,0,(MenuFunc)mmi_fv_reame_edit,item_flag_none}
201
202 };
203
204 static const MfwMnuAttr Mmi_fv_OPTAttrib =
205 {
206 &SmsSend_R_OPTArea,
207 MNU_LEFT | MNU_LIST | MNU_CUR_LINE, /* centered page menu */
208 -1, /* use default font */
209 (MfwMnuItem*)Mmi_fv_OPTItems, /* with these items */
210 sizeof(Mmi_fv_OPTItems)/sizeof(MfwMnuItem), /* number of items */
211 COLOUR_LIST_SMS, TxtNull, NULL, MNUATTRSPARE
212
213 };
214
215 //Variable definition
216 T_fv_menu fv_menu_data = {0};
217 //Variable to store the max jpeg file count.
218 int file_count = 0;
219
220 //Array to store the Jpeg filenames.
221 UBYTE jpegFiles[FV_MAX_NUM_FILES][FV_FILE_NAME_LENGTH] = {0};
222
223 //Buffer to store the jpeg image from FFS.
224
225 static UBYTE jpeg_test_array[FV_MAX_JPEG_SIZE] = {0};
226
227 T_MFW_HND fv_optwin;
228
229 UBYTE zoom_flag,rotate_flag = 0; //Flag to identify the rotate and zooming
230
231 //Function prototypes
232
233 static int mmi_fv_list_files_win_cb (MfwEvt e, MfwWin *w);
234 static void mmi_fv_menu_listmnu_cb(T_MFW_HND Parent, ListMenuData * ListData);
235 void mmi_fv_list_files_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
236 static T_MFW_HND mmi_fv_list_files_create(T_MFW_HND parent_window, void* callfun);
237 static T_MFW_HND mmi_fv_test_select_file (T_MFW_HND parent_win);
238 static int mmi_fv_opt_mnu_cb (MfwEvt e, MfwMnu *m);
239 static int mmi_fv_opt_kbd_cb (MfwEvt e, MfwKbd *k);
240 static int mmi_fv_opt_win_cb (MfwEvt e, MfwWin *w);
241 void mmi_fv_opt_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
242 static void mmi_fv_delete_cb (T_MFW_HND win, USHORT Identifier, SHORT reason);
243 static void mmi_rename_editor_cb(T_MFW_HND win, USHORT identifier, SHORT reason);
244 MfwRes mmi_fv_editor_destroy(T_MFW_HND win);
245 void mmi_fv_editor_cntrl (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
246 T_MFW_HND mmi_fv_editor_create(T_MFW_HND parent);
247 static int mmi_fv_view_kbd_cb (MfwEvt e, MfwKbd *k);
248 static int mmi_fv_view_win_cb (MfwEvt e, MfwWin w);
249 static T_MFW_HND mmi_fv_view_image_create(MfwHnd parent_window);
250 static void mmi_fv_view_exec_cb(T_MFW_HND win, USHORT event, void *parameter);
251 static int mmi_fv_rotate_win_cb (MfwEvt e, MfwWin w);
252 static int mmi_fv_rotate_kbd_cb (MfwEvt e, MfwKbd *k);
253 static void mmi_fv_rotate_exec_cb(T_MFW_HND win, USHORT event, void *parameter);
254 static int mmi_fv_zoom_win_cb (MfwEvt e, MfwWin w);
255 static int mmi_fv_zoom_kbd_cb (MfwEvt e, MfwKbd *k);
256 static void mmi_fv_zoom_exec_cb(T_MFW_HND win, USHORT event, void *parameter);
257 static MfwHnd mmi_fv_test_show_info(T_MFW_HND parent,int lsk, int rsk, int str1, int str2, T_VOID_FUNC callback);
258 static int mmi_fv_item_mnu_cb(MfwMnu * mnu, MfwMnuItem * item);
259 static void mmi_fv_menu_destroy(MfwHnd window);
260 static T_MFW_HND mmi_fv_opt_create(MfwHnd parent_window);
261 GLOBAL int mmi_fv_delete_jpeg_file(UBYTE index);
262 static T_MFW_HND mmi_fv_rotate_image_create(MfwHnd parent_window);
263 int mmi_fv_zoom_image_start(T_MFW_HND parent) ;
264 static T_MFW_HND mmi_fv_zoom_image_create(MfwHnd parent_window);
265
266 /*******************************************************************************
267
268 $Function: mmi_fv_get_file_count
269
270 $Description: returns the count of jpeg files
271
272 $Returns: The file count of the files in JPG folder.
273
274 $Arguments:None
275
276 *******************************************************************************/
277 UBYTE mmi_fv_get_file_count()
278 {
279 return file_count;
280 }
281
282
283 /*******************************************************************************
284
285 $Function: LaunchFileViewer
286
287 $Description: Initiates the creation of the jpeg file list window and post init event
288
289 $Returns: Execution status
290
291 $Arguments: m - pointer to current menu
292 i - pointer to current menu item
293
294 *******************************************************************************/
295 GLOBAL int LaunchFileViewer( MfwMnu *m, MfwMnuItem *i )
296 {
297 T_MFW_HND win;
298 T_MFW_HND parent_win = mfw_parent(mfw_header());
299
300 TRACE_FUNCTION ("LaunchFileViewer()");
301
302 mfw_fv_init();
303 win = mmi_fv_list_files_create(parent_win,(void*)mmi_fv_list_files_exec_cb);
304
305 if (win NEQ NULL)
306 {
307 SEND_EVENT (win, FV_INIT, 0, 0);
308 }
309 return MFW_EVENT_CONSUMED;
310 }
311
312 /*******************************************************************************
313
314 $Function: mmi_fileviewer_list_files_create
315
316 $Description: Creates the window and dialog handler for the window that
317 holds the list window
318
319 $Returns: Window Handler
320
321 $Arguments:parent_window - Parent Window
322 callfun- Callback function
323
324 *******************************************************************************/
325
326 static T_MFW_HND mmi_fv_list_files_create(T_MFW_HND parent_window, void* callfun)
327 {
328 T_fv_menu * data = (T_fv_menu *)mfwAlloc(sizeof (T_fv_menu));
329 T_MFW_WIN * win;
330 TRACE_FUNCTION ("mmi_fileviewer_list_files_create");
331
332 /* Create window handler */
333
334 data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)mmi_fv_list_files_win_cb);
335 if (data->win EQ NULL)
336 {
337 return NULL;
338 }
339
340 TRACE_EVENT("list holder window created: " );
341 /* connect the dialog data to the MFW-window */
342
343 data->mmi_control.dialog = (T_DIALOG_FUNC)callfun;
344 data->mmi_control.data = data;
345 win = ((T_MFW_HDR *)data->win)->data;
346 win->user = (void *)data;
347 data->parent = parent_window;
348 winShow(data->win);
349 /*
350 * return window handle
351 */
352
353 return data->win;
354 }
355
356 /*******************************************************************************
357
358 $Function: mmi_fv_list_files_exec_cb
359
360 $Description: handler for the window that holds the list window
361
362 $Returns:None
363
364 $Arguments: win : The pointer to the window handler, so the function can reference the
365 dynamic user data, if any.
366 event : The incoming event
367 value : Generic incoming Parameter, it will be 'event' dependant
368 parameter : Generic incoming Parameter, it will be 'event' dependant
369
370 *******************************************************************************/
371 void mmi_fv_list_files_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
372 {
373 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
374 T_fv_menu * data = (T_fv_menu *)win_data->user;
375
376 TRACE_FUNCTION ("mmi_fv_list_files_exec_cb");
377
378 switch (event)
379 {
380 case FV_INIT:
381 data->fv_menu = mmi_fv_test_select_file(win);
382 if(data->fv_menu == NULL)
383 mmi_fv_menu_destroy((MfwHnd)data->win);
384 break;
385 case FV_RETURN:
386 default:
387 break;
388 }
389 }
390
391 /*******************************************************************************
392
393 $Function: mmi_fv_list_files_win_cb
394
395 $Description: window callback for the window that holds the list window
396
397 $Returns:Status
398
399 $Arguments: e - window handle event
400 w - window
401
402
403 *******************************************************************************/
404 static int mmi_fv_list_files_win_cb (MfwEvt e, MfwWin *w)
405 {
406 TRACE_FUNCTION ("mmi_fv_list_files_win_cb()");
407 switch (e)
408 {
409 case MfwWinVisible: /* window is visible */
410 break;
411 case MfwWinFocussed: /* input focus / selected */
412 case MfwWinDelete: /* window will be deleted */
413
414 default:
415 return MFW_EVENT_REJECTED;
416 }
417 return MFW_EVENT_CONSUMED;
418 }
419
420
421 /*******************************************************************************
422
423 $Function: mmi_fv_test_select_file
424
425 $Description: browse jpeg files and enable to select them
426
427 $Returns: T_MFW_HND : Window Handle to the New Window, Null if failed.
428
429 $Arguments: parent : pointer to the parent window.
430
431
432 *******************************************************************************/
433 static T_MFW_HND mmi_fv_test_select_file (T_MFW_HND parent_win)
434 {
435 int j;
436 T_fv_menu *data;
437 T_MFW_HND win = parent_win;
438 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
439
440
441 TRACE_FUNCTION ("mmi_fv_test_select_file()");
442 //Populate the jpeg files from ffs
443 mmi_fv_init(&file_count);
444
445 data = (T_fv_menu *)win_data->user;
446 if (data->win EQ NULL)
447 {
448 return NULL;
449 }
450 //set count to 0
451 data->fv_file_count = 0;
452
453 //In case no files are present in ffs return info message
454 if(file_count == 0)
455 {
456 mmi_fv_test_show_info(0,TxtNull,TxtNull, TxtFileNotLoaded, TxtNull, NULL);
457 return NULL;
458 }
459 else
460 {
461 /* Create the list menu to display the results */
462 /* initialization of the dialog data */
463 data->fv_list_data.ListPosition = 1;/* True cursor position in list menu. */
464 data->fv_list_data.Font = 0;
465 data->fv_list_data.LeftSoftKey = TxtSoftOptions;
466 data->fv_list_data.RightSoftKey = TxtSoftBack;
467 data->fv_list_data.KeyEvents = KEY_CLEAR | KEY_RIGHT | KEY_LEFT | KEY_MNUUP | KEY_MNUDOWN |KEY_HUP;
468 data->fv_list_data.Reason = 0;
469 data->fv_list_data.Strings = TRUE;
470 data->fv_list_data.autoDestroy = TRUE;
471 data->fv_list_data.Attr = (MfwMnuAttr *)&menuFvSearchListAttr;
472 data->fv_list_data.Attr->hdrId = TxtFileViewer;
473 data->fv_list_data.Attr->nItems = file_count;
474 data->fv_list_cb = (ListCbFunc)mmi_fv_menu_listmnu_cb;
475 data->fv_list_data.ListLength = file_count; /* actual number of entries in list menu. */
476 data->fv_list_data.List = (MfwMnuItem *)mfwAlloc(data->fv_list_data.ListLength * sizeof (MfwMnuItem));
477 if (data->fv_list_data.List != (MfwMnuItem *)0)
478 {
479 MfwMnuItem *listItem;
480
481 /* Initialise the memory to 0x00 */
482 memset(data->fv_list_data.List, 0x00, data->fv_list_data.ListLength * sizeof (MfwMnuItem));
483
484 for (j = 0; j <data->fv_list_data.ListLength; j++)
485 {
486 listItem = &data->fv_list_data.List[j];
487 listItem->str = (char*)jpegFiles[data->fv_file_count++];
488 listItem->func = (MenuFunc)mmi_fv_item_mnu_cb;
489 listItem->flagFunc = (FlagFunc)item_flag_none;
490 }
491
492 /* Recreate the menu with the new details */
493 if (listDisplayListMenu(data->win, &data->fv_list_data, data->fv_list_cb, FALSE) != LISTS_FAIL)
494 return data->fv_list_data.win;
495
496 }
497 return data->win;
498 }
499
500 }
501
502 /*******************************************************************************
503
504 $Function: mmi_fv_test_show_info
505
506 $Description: This function displays a information screen with the textId's
507
508 $Returns: Dialog Window
509
510 $Arguments:parent- parent win
511 lsk- Left Softkey
512 rsk-Right Softkey
513 str1-String
514 str2-String
515 callback- Callback function
516
517 *******************************************************************************/
518 static MfwHnd mmi_fv_test_show_info(T_MFW_HND parent,int lsk, int rsk, int str1, int str2, T_VOID_FUNC callback)
519 {
520 T_DISPLAY_DATA display_info;
521
522 TRACE_FUNCTION ("mmi_fv_test_show_info()");
523
524 /*
525 ** Create a timed dialog to display the Message
526 */
527 dlg_initDisplayData_TextId( &display_info, lsk, rsk, str1, str2, COLOUR_STATUS);
528 dlg_initDisplayData_events( &display_info, callback, FV_INFO_SCRN_TIMEOUT, KEY_LEFT | KEY_CLEAR | KEY_HUP);
529
530 return info_dialog(parent, &display_info);
531 }
532
533 /*******************************************************************************
534
535 $Function: mmi_fv_init
536
537 $Description: Function retrieves the files present under the /JPG directory
538
539 $Returns: None
540
541 $Arguments: Filecount- count of files in FFS.
542
543 *******************************************************************************/
544 void mmi_fv_init(int* fileCount)
545 {
546
547 T_FFS_FD fd = 0;
548 char dir_name_p[] = FV_DIR_NAME;
549 T_FFS_DIR dir = {0};
550 char dest_name_p[FV_FILE_NAME_LENGTH] = "";
551 int i, max_files_count = 0;
552 char *fileExt;
553
554 TRACE_FUNCTION("mmi_fv_init()");
555
556 i = strlen(dir_name_p);
557 dir_name_p[i-1] = '\0';
558
559 TRACE_EVENT_P1("the dir name = %s",dir_name_p);
560
561 if ((max_files_count = ffs_opendir (dir_name_p, &dir)) <= 0)
562 {
563 return;
564 }
565
566 //Display only 10 files
567 if(max_files_count > FV_MAX_NUM_FILES)
568 max_files_count = FV_MAX_NUM_FILES;
569
570 *fileCount = max_files_count;
571 TRACE_EVENT_P1("Number of files = %d",*fileCount);
572
573 //read maximum of 10 file names
574 for (i = 0; (ffs_readdir (&dir, dest_name_p, 100) > 0x0) && (i<max_files_count); i++)
575 {
576 if(i >= FV_MAX_NUM_FILES)
577 break;
578
579 //retrieve file extension
580 fileExt = mmi_fv_GetExtension(dest_name_p);
581 //Store only jpeg file names in array
582 if ( (strcmp(fileExt, "jpg") == 0))
583 {
584 strcpy ((char*)jpegFiles[i], dest_name_p);
585 }
586 memset(dest_name_p,0,FV_FILE_NAME_LENGTH);
587 }
588
589 TRACE_EVENT_P1("Number of files after read = %d",*fileCount);
590 }
591
592 /*******************************************************************************
593
594 $Function: mmi_fv_item_mnu_cb
595
596 $Description: save index of currently selected file
597
598 $Returns:
599
600 $Arguments: m - pointer to current menu
601 i - pointer to current menu item
602
603 *******************************************************************************/
604 static int mmi_fv_item_mnu_cb(MfwMnu * mnu, MfwMnuItem * item)
605 {
606 T_MFW_HND win = mfw_parent(mfw_header());
607 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
608 T_fv_menu *data = (T_fv_menu *)win_data->user;
609
610 TRACE_FUNCTION ("mmi_fv_item_mnu_cb()");
611 if (data EQ NULL)
612 {
613 return NULL;
614 }
615 data->fv_list_idx = fv_menu_data.fv_list_idx = mnu->lCursor[mnu->level];
616 data->fv_option_win = mmi_fv_opt_start(data->win,(MfwMnuAttr*)&Mmi_fv_OPTAttrib);
617 return MFW_EVENT_CONSUMED;
618 }
619
620
621 /*******************************************************************************
622
623 $Function: mmi_fv_menu_listmnu_cb
624
625 $Description: destroy lists and menu in case of back softkey or menu exit
626
627 $Returns:None
628
629 $Arguments:parent-
630 Listadata-
631
632 *******************************************************************************/
633 static void mmi_fv_menu_listmnu_cb(T_MFW_HND Parent, ListMenuData * ListData)
634 {
635 T_MFW_WIN *win_data = ((T_MFW_HDR *)Parent)->data;
636 T_fv_menu *data = (T_fv_menu *)win_data->user;
637
638 TRACE_FUNCTION ("mmi_fv_menu_listmnu_cb()");
639
640 if ((ListData->Reason EQ LISTS_REASON_BACK) ||
641 (ListData->Reason EQ LISTS_REASON_CLEAR) ||
642 (ListData->Reason EQ LISTS_REASON_HANGUP))
643 {
644
645 /* Free the memory set aside for ALL the devices to be listed.*/
646 mfwFree((U8 *)data->fv_list_data.List, (U16)(ListData->ListLength* sizeof(MfwMnuItem)));
647 listsDestroy(ListData->win);
648 data->fv_list_data.List = NULL;
649 mmi_fv_menu_destroy((MfwHnd)data->win);
650 }
651
652 return;
653 }
654
655 /*******************************************************************************
656
657 $Function: mmi_fv_menu_destroy
658
659 $Description: destroy menu window
660
661 $Returns:None
662
663 $Arguments: window : pointer to the parent window.
664
665 *******************************************************************************/
666 static void mmi_fv_menu_destroy(MfwHnd window)
667 {
668 T_MFW_WIN * win_data = ((T_MFW_HDR *)window)->data;
669 T_fv_menu * data = (T_fv_menu *)win_data->user;
670
671 TRACE_FUNCTION ("mmi_fv_menu_destroy()");
672
673 if (window == NULL)
674 {
675 return;
676 }
677
678 if (data)
679 {
680 win_delete(data->win);
681 /* Free Memory */
682 mfwFree((void *)data, sizeof (T_fv_menu));
683 }
684 }
685
686
687 /*******************************************************************************
688
689 $Function: mmi_fv_set_rotate_90degree
690
691 $Description: Rotates the selected image by 90 degree.
692 $Returns: Status
693
694 $Arguments:m - pointer to current menu
695 i - pointer to current menu item
696
697 *******************************************************************************/
698 GLOBAL int mmi_fv_set_rotate_90degree (MfwMnu* m, MfwMnuItem* i)
699 {
700 T_MFW_HND win = mfwParent(mfw_header());
701 TRACE_FUNCTION ("mmi_fv_set_rotate_90degree()");
702 rotate_flag = FV_ROTATE_90;
703 mmi_fv_rotate_image_start(win);
704 return MFW_EVENT_CONSUMED;
705 }
706
707 /*******************************************************************************
708
709 $Function: mmi_fv_set_rotate_180degree
710
711 $Description: Rotates the selected image by 180 degree.
712 $Returns: Status
713
714 $Arguments:m - pointer to current menu
715 i - pointer to current menu item
716
717 *******************************************************************************/
718 GLOBAL int mmi_fv_set_rotate_180degree (MfwMnu* m, MfwMnuItem* i)
719 {
720 T_MFW_HND win = mfwParent(mfw_header());
721 TRACE_FUNCTION ("mmi_fv_set_rotate_180degree()");
722 rotate_flag = FV_ROTATE_180;
723 mmi_fv_rotate_image_start(win);
724 return MFW_EVENT_CONSUMED;
725 }
726
727
728 /*******************************************************************************
729
730 $Function: mmi_fv_set_rotate_270degree
731
732 $Description: Rotates the selected image anti-clockwise.
733 $Returns:
734
735 $Arguments: m - pointer to current menu
736 i - pointer to current menu item
737
738 *******************************************************************************/
739 GLOBAL int mmi_fv_set_rotate_270degree (MfwMnu* m, MfwMnuItem* i)
740 {
741 T_MFW_HND win = mfwParent(mfw_header());
742 TRACE_FUNCTION ("mmi_fv_set_rotate_270degree()");
743 rotate_flag = FV_ROTATE_270;
744 mmi_fv_rotate_image_start(win);
745 return MFW_EVENT_CONSUMED;
746 }
747
748 /*******************************************************************************
749
750 $Function: mmi_fv_set_zoom_out
751
752 $Description: Zooms out the selected image
753 $Returns:
754
755 $Arguments: m - pointer to current menu
756 i - pointer to current menu item
757
758 *******************************************************************************/
759 GLOBAL int mmi_fv_set_zoom_out (MfwMnu* m, MfwMnuItem* i)
760 {
761 T_MFW_HND win = mfwParent(mfw_header());
762 TRACE_FUNCTION ("mmi_fv_set_zoom_out()");
763 zoom_flag = FV_ZOOM_OUT;
764 mmi_fv_zoom_image_start(win);
765 return MFW_EVENT_CONSUMED;
766 }
767
768 /*******************************************************************************
769
770 $Function: mmi_fv_set_zoom_in
771
772 $Description: Zooms in the selected image
773 $Returns:
774
775 $Arguments: m - pointer to current menu
776 i - pointer to current menu item
777
778 *******************************************************************************/
779 GLOBAL int mmi_fv_set_zoom_in (MfwMnu* m, MfwMnuItem* i)
780 {
781 T_MFW_HND win = mfwParent(mfw_header());
782 TRACE_FUNCTION ("mmi_fv_set_zoom_in()");
783 zoom_flag = FV_ZOOM_IN;
784 mmi_fv_zoom_image_start(win);
785 return MFW_EVENT_CONSUMED;
786 }
787
788 /*******************************************************************************
789
790 $Function: mmi_fv_view_image_start
791
792 $Description: Create editor for viewing the image.
793
794 $Returns: none
795
796 $Arguments: m - menu handler
797 i - menu item selected.
798 *******************************************************************************/
799
800
801 int mmi_fv_view_image_start(MfwMnu* m, MfwMnuItem* i)
802 {
803 T_MFW_HND win;
804 T_MFW_HND parent_win = mfw_parent(mfw_header());
805 win = mmi_fv_view_image_create(parent_win);
806 TRACE_FUNCTION ("mmi_fv_view_image_start");
807 SEND_EVENT(win,FV_INIT,FV_OPT_ID,0);
808 return MFW_EVENT_CONSUMED;
809
810 }
811
812
813 /*******************************************************************************
814
815 $Function: mmi_fv_view_image_create
816
817 $Description: Create a window for viewing the image.
818
819 $Returns: window handle
820
821 $Arguments: parent_window - parent window.
822
823 *******************************************************************************/
824
825 static T_MFW_HND mmi_fv_view_image_create(MfwHnd parent_window)
826 {
827 T_fv_opt* data = (T_fv_opt *)ALLOC_MEMORY (sizeof (T_fv_opt));
828 T_MFW_WIN * win;
829
830 TRACE_FUNCTION ("mmi_fv_view_image_create()");
831
832 // Create window handler
833 data->win = win_create (parent_window, 0, E_WIN_VISIBLE,(MfwCb)mmi_fv_view_win_cb);
834 if (data->win EQ NULL)
835 {
836 return NULL;
837 }
838
839 // connect the dialog data to the MFW-window
840 data->mmi_control.dialog = (T_DIALOG_FUNC)mmi_fv_view_exec_cb;
841 data->mmi_control.data = data;
842 win = ((T_MFW_HDR *)data->win)->data;
843 win->user = (MfwUserDataPtr)data;
844 data->parent = parent_window;
845 //Create keyboard handler
846 data->kbd = kbd_create (data->win,KEY_ALL,(T_MFW_CB)mmi_fv_view_kbd_cb);
847
848 return data->win;
849 }
850
851
852 /*******************************************************************************
853
854 $Function: mmi_fv_view_exec_cb
855
856 $Description: Callback handler for events sent by the images editor
857
858 $Returns: none
859
860 $Arguments: win - current window
861 event - event id
862 parameter - optional data.
863 *******************************************************************************/
864
865 static void mmi_fv_view_exec_cb(T_MFW_HND win, USHORT event, void *parameter)
866 {
867 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
868 T_fv_opt * data = (T_fv_opt *)win_data->user;
869 int status;
870
871 TRACE_FUNCTION ("mmi_fv_view_exec_cb()");
872
873 switch (event)
874 {
875 case FV_INIT:
876 TRACE_EVENT("init");
877 status = mmi_fv_read_jpeg_file(fv_menu_data.fv_list_idx);
878
879 //Display the decoded jpeg image in QCIF-RGB565 format on LCD.
880 if(status == 1)
881 winShow(data->win);
882 else
883 mmi_fv_test_show_info(0,TxtNull,TxtNull, TxtFileTooBig, TxtNull, NULL);
884 break;
885
886 case FV_RETURN:
887 break;
888 default:
889 TRACE_EVENT("Err: Default");
890 return;
891 }
892 }
893
894
895 /*******************************************************************************
896
897 $Function: mmi_fv_opt_start
898
899 $Description: called when the user press the Option menu
900
901 $Returns: execution status
902
903 $Arguments: parent_window -parent window handle
904 menuAttr - Menu attributes.
905
906 *******************************************************************************/
907
908 T_MFW_HND mmi_fv_opt_start(T_MFW_HND parent_window, MfwMnuAttr *menuAttr)
909 {
910 T_MFW_HND win;
911
912 TRACE_FUNCTION ("mmi_fv_opt_start()");
913
914 fv_optwin = (T_MFW_HND)mmi_fv_opt_create ((MfwHnd)parent_window);
915
916 if (fv_optwin NEQ NULL)
917 {
918 SEND_EVENT (fv_optwin, FV_INIT, NULL, (void *)menuAttr);
919 }
920 return fv_optwin;
921 }
922
923 /*******************************************************************************
924
925 $Function: mmi_fv_opt_create
926
927 $Description: Create the Option window
928
929 $Returns: mfw window handle
930
931 $Arguments: parent_window -parent window handle
932
933 *******************************************************************************/
934
935 static T_MFW_HND mmi_fv_opt_create(MfwHnd parent_window)
936 {
937 T_fv_opt * data = (T_fv_opt *)ALLOC_MEMORY (sizeof (T_fv_opt));
938 T_MFW_WIN * win;
939
940 TRACE_FUNCTION ("mmi_fv_opt_create()");
941
942 /*
943 * Create window handler
944 */
945
946 data->win =
947 win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)mmi_fv_opt_win_cb);
948 if (data->win EQ NULL)
949 {
950 return NULL;
951 }
952 /*
953 * connect the dialog data to the MFW-window
954 */
955
956 data->mmi_control.dialog = (T_DIALOG_FUNC)mmi_fv_opt_exec_cb;
957 data->mmi_control.data = data;
958 win = ((T_MFW_HDR *)data->win)->data;
959 win->user = (void *)data;
960 data->parent = parent_window;
961
962 /*
963 * return window handle
964 */
965
966 return data->win;
967 }
968
969 /*******************************************************************************
970
971 $Function: mmi_fv_opt_destroy
972
973 $Description: Destroy the Option window
974
975 $Returns: mfw window handle
976
977 $Arguments: own_window - current window
978
979 *******************************************************************************/
980
981 static void mmi_fv_opt_destroy(MfwHnd own_window)
982 {
983 T_MFW_WIN * win_data;
984 T_fv_opt * data;
985
986 TRACE_FUNCTION ("mmi_fv_opt_destroy()");
987
988 if (own_window)
989 {
990 win_data = ((T_MFW_HDR *)own_window)->data;
991 data = (T_fv_opt *)win_data->user;
992
993 if (data)
994 {
995 /*
996 * Delete WIN handler
997 */
998
999 if (data->kbd)
1000 {
1001 kbd_delete(data->kbd);
1002 data->kbd = NULL;
1003 }
1004 if (data->kbd_long)
1005 {
1006 kbd_delete(data->kbd_long);
1007 data->kbd_long = NULL;
1008 }
1009 if (data->menu)
1010 {
1011 mnuDelete(data->menu);
1012 data->menu=NULL;
1013 }
1014
1015 win_delete (data->win);
1016
1017 /*
1018 * Free Memory
1019 */
1020 FREE_MEMORY ((void *)data, sizeof (T_fv_opt));
1021 }
1022 else
1023 {
1024 TRACE_EVENT ("mmi_fv_opt_destroy() called twice");
1025 }
1026 }
1027 }
1028
1029
1030 /*******************************************************************************
1031
1032 $Function: mmi_fv_opt_win_cb
1033
1034 $Description: Window callback function for the Option window
1035
1036 $Returns: execution status
1037
1038 $Arguments: e - event id
1039 w - window handle
1040 *******************************************************************************/
1041
1042 static int mmi_fv_opt_win_cb (MfwEvt e, MfwWin *w)
1043 {
1044 TRACE_FUNCTION ("mmi_fv_opt_win_cb()");
1045
1046 switch (e)
1047 {
1048 case MfwWinVisible: /* window is visible */
1049 dspl_ClearAll();
1050 displaySoftKeys(TxtSoftSelect,TxtSoftBack);
1051 break;
1052 case MfwWinFocussed: /* input focus / selected */
1053 case MfwWinDelete: /* window will be deleted */
1054 default:
1055 return MFW_EVENT_REJECTED;
1056 }
1057 return MFW_EVENT_CONSUMED;
1058 }
1059
1060
1061 /*******************************************************************************
1062
1063 $Function: mmi_fv_view_win_cb
1064
1065 $Description: Window callback function for the Option window
1066
1067 $Returns: execution status
1068
1069 $Arguments: e - event id
1070 w - window handle
1071 *******************************************************************************/
1072
1073 static int mmi_fv_view_win_cb (MfwEvt e, MfwWin w)
1074 {
1075 TRACE_FUNCTION ("mmi_fv_view_win_cb()");
1076
1077 switch (e)
1078 {
1079 case MfwWinVisible: /* window is visible */
1080 dspl_ClearAll();
1081 displaySoftKeys(TxtSoftOptions,TxtSoftBack);
1082 //Display the image now.
1083 mmi_fv_display_image();
1084 break;
1085 case MfwWinFocussed: /* input focus / selected */
1086 case MfwWinDelete: /* window will be deleted */
1087 default:
1088 return MFW_EVENT_REJECTED;
1089 }
1090 return MFW_EVENT_CONSUMED;
1091 }
1092 /*******************************************************************************
1093
1094 $Function: mmi_fv_opt_exec_cb
1095
1096 $Description: Exec callback function for the Option window
1097
1098 $Returns: none
1099
1100 $Arguments: win - current window
1101 event - event id
1102 value - unique id
1103 parameter - optional data.
1104
1105 *******************************************************************************/
1106
1107 void mmi_fv_opt_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
1108 {
1109 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1110 T_fv_opt * data = (T_fv_opt *)win_data->user;
1111 T_MFW_HDR * parent = data->parent;
1112 T_MFW_WIN * win_data2 = ((T_MFW_HDR *)parent)->data;
1113 T_fv_menu* parent_data = (T_fv_menu *)win_data2->user;
1114
1115
1116 TRACE_FUNCTION ("mmi_fv_opt_exec_cb()");
1117
1118
1119 switch (event)
1120 {
1121 case FV_INIT:
1122
1123 TRACE_EVENT("mmi_fv_opt_exec_cb() Event:5.FV_INIT");
1124 /* initialization of administrative data */
1125 data->parent_data = parent_data;
1126 data->id = value;
1127 data->kbd = kbdCreate(data->win,KEY_ALL, (MfwCb)mmi_fv_opt_kbd_cb);
1128 data->kbd_long = kbdCreate(data->win,KEY_ALL|KEY_LONG,(MfwCb)mmi_fv_opt_kbd_cb);
1129 data->menu = mnuCreate(data->win,(MfwMnuAttr*)parameter, E_MNU_ESCAPE, (MfwCb)mmi_fv_opt_mnu_cb);
1130 mnuLang(data->menu,mainMmiLng);
1131 /* put the (new) dialog window on top of the window stack */
1132 mnuUnhide(data->menu);
1133 winShow(win);
1134 break;
1135 default:
1136 return;
1137 }
1138 }
1139
1140 /*******************************************************************************
1141
1142 $Function: mmi_fv_opt_kbd_cb
1143
1144 $Description: Exec callback function for the Option window
1145
1146 $Returns: execution status
1147
1148 $Arguments: e - event id
1149 k - keyboard info
1150 *******************************************************************************/
1151
1152 static int mmi_fv_opt_kbd_cb (MfwEvt e, MfwKbd *k)
1153 {
1154 T_MFW_HND win = mfwParent(mfw_header());
1155 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1156 T_fv_opt * data = (T_fv_opt *)win_data->user;
1157
1158 TRACE_FUNCTION ("mmi_fv_opt_kbd_cb()");
1159
1160 if (e & KEY_LONG)
1161 {
1162 switch (k->code)
1163 {
1164 case KCD_HUP: /* back to previous menu */
1165 mnuEscape(data->menu);
1166 break;
1167 case KCD_RIGHT: /* Power Down */
1168 return MFW_EVENT_REJECTED; /* handled by idle */
1169 default: /* no response to all other keys */
1170 return MFW_EVENT_CONSUMED;
1171 }
1172 }
1173 else
1174 {
1175 switch (k->code)
1176 {
1177 case KCD_MNUUP: /* highlight previous entry */
1178 mnuUp(data->menu);
1179 break;
1180 case KCD_MNUDOWN: /* highlight next entry */
1181 mnuDown(data->menu);
1182 break;
1183 case KCD_MNUSELECT:
1184 case KCD_LEFT: /* activate this entry */
1185 mnuSelect(data->menu);
1186 break;
1187 case KCD_HUP: /* back to previous menu */
1188 case KCD_RIGHT: /* back to previous menu */
1189 mnuEscape(data->menu);
1190 break;
1191 default: /* no response to all other keys */
1192 return MFW_EVENT_CONSUMED;
1193 }
1194 }
1195 return MFW_EVENT_CONSUMED;
1196 }
1197
1198 /*******************************************************************************
1199
1200 $Function: mmi_fv_view_kbd_cb
1201
1202 $Description: Exec callback function for the view window
1203
1204 $Returns: execution status
1205
1206 $Arguments: e - event id
1207 k - keyboard info
1208 *******************************************************************************/
1209
1210 static int mmi_fv_view_kbd_cb (MfwEvt e, MfwKbd *k)
1211 {
1212 T_MFW_HND win = mfwParent(mfw_header());
1213 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1214 T_fv_opt * data = (T_fv_opt *)win_data->user;
1215
1216 TRACE_FUNCTION ("mmi_fv_view_kbd_cb()");
1217
1218 switch (k->code)
1219 {
1220 case KCD_LEFT:
1221 TRACE_EVENT("mmi_fv_view_kbd_cb,INFO_KCD_LEFT ");
1222 bookMenuStart(data->win, ViewOptionsMenuAttributes(),0);
1223 break;
1224
1225 case KCD_RIGHT:
1226 case KCD_HUP:
1227 TRACE_EVENT("mmi_fv_view_kbd_cb,INFO_KCD_RIGHT ");
1228 mmi_fv_opt_destroy(data->win);
1229 break;
1230 default:
1231
1232 break;
1233
1234 }
1235 return MFW_EVENT_CONSUMED;
1236 }
1237
1238 /*******************************************************************************
1239
1240 $Function: mmi_fv_opt_mnu_cb
1241
1242 $Description: Menu callback function for the Option window
1243
1244 $Returns: none
1245
1246 $Arguments: e - event id
1247 m - menu handle
1248 *******************************************************************************/
1249
1250 static int mmi_fv_opt_mnu_cb (MfwEvt e, MfwMnu *m)
1251
1252 {
1253 T_MFW_HND win = mfwParent(mfw_header());
1254 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1255 T_fv_opt * data = (T_fv_opt *)win_data->user;
1256
1257 TRACE_FUNCTION ("mmi_fv_opt_mnu_cb()");
1258
1259 switch (e)
1260 {
1261 case E_MNU_ESCAPE: /* back to previous menu */
1262 mmi_fv_opt_destroy(data->win);
1263 break;
1264 default: /* in mnuCreate() only E_MNU_ESCAPE has been enabled! */
1265 return MFW_EVENT_REJECTED;
1266 }
1267 return MFW_EVENT_CONSUMED;
1268 }
1269
1270 /*******************************************************************************
1271
1272 $Function: mmi_fv_rotate_start
1273
1274 $Description: This function creates and displays the Roate menu .
1275
1276 $Returns: Execution status
1277
1278 $Arguments: m - menu handler
1279 i - Menu item selected
1280
1281 *******************************************************************************/
1282
1283 int mmi_fv_rotate_start(MfwMnu* m, MfwMnuItem* i)
1284 {
1285
1286 T_MFW_HND win = mfwParent(mfw_header());
1287 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1288 T_fv_opt * data = (T_fv_opt *)win_data->user;
1289 TRACE_FUNCTION("mmi_fv_rotate_start");
1290 if (data->win EQ NULL)
1291 {
1292 return NULL;
1293 }
1294
1295 /* Create the Rotate menu*/
1296 bookMenuStart(data->win, rotateMenuAttributes(),0);
1297
1298 return MFW_EVENT_CONSUMED;
1299 }
1300
1301 /*******************************************************************************
1302
1303 $Function: mmi_fv_zoom_start
1304
1305 $Description: This function creates and displays the Zoom menu .
1306
1307 $Returns: Execution status
1308
1309 $Arguments: m - menu handler
1310 i - Menu item selected
1311
1312 *******************************************************************************/
1313
1314 int mmi_fv_zoom_start(MfwMnu* m, MfwMnuItem* i)
1315 {
1316
1317 T_MFW_HND win = mfwParent(mfw_header());
1318 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
1319 T_fv_opt * data = (T_fv_opt *)win_data->user;
1320 TRACE_FUNCTION("mmi_fv_zoom_start");
1321 if (data->win EQ NULL)
1322 {
1323 return NULL;
1324 }
1325
1326 /* Create the Zoom menu*/
1327 bookMenuStart(data->win, zoomMenuAttributes(),0);
1328
1329 return MFW_EVENT_CONSUMED;
1330 }
1331
1332 /*******************************************************************************
1333
1334 $Function: mmi_fv_GetExtension
1335
1336 $Description: public function to retrieve the extension of a file
1337
1338 $Returns:Extention of the filename
1339
1340 $Arguments: scr- Filename
1341
1342 *******************************************************************************/
1343 char *mmi_fv_GetExtension(char *src)
1344 {
1345 int i;
1346 TRACE_FUNCTION("mmi_fv_GetExtension");
1347 for(i = 0; i < strlen(src); i++){
1348 if(src[i] == '.'){
1349 return (src+i+1);
1350 }
1351 }
1352 return (src+i);
1353 }
1354
1355
1356 /*******************************************************************************
1357
1358 $Function: mmi_fv_delete_start
1359
1360 $Description: This function is called when the user press Delete .
1361
1362 $Returns: Execution status
1363
1364 $Arguments: m - menu handler
1365 i - Menu item selected
1366
1367 *******************************************************************************/
1368 int mmi_fv_delete_start(MfwMnu* m, MfwMnuItem* i)
1369 {
1370 T_MFW_HND win = mfwParent(mfw_header());
1371 T_DISPLAY_DATA display_info;
1372
1373 TRACE_FUNCTION("mmi_fv_delete_start");
1374 //Check whether files are present
1375 if ( mmi_fv_get_file_count() == 0)
1376 {
1377 /*tell user*/
1378 mmi_fv_test_show_info(0,TxtNull,TxtNull, TxtEmptyList, TxtNull, NULL);
1379 }
1380 else
1381 {
1382 TRACE_EVENT("files are present");
1383 TRACE_EVENT_P1("delete_index is %d",fv_menu_data.fv_list_idx);
1384 TRACE_EVENT_P1("The selected file = %s",jpegFiles[fv_menu_data.fv_list_idx]);
1385 dlg_initDisplayData_TextId( &display_info, TxtSoftOK, TxtSoftBack, TxtDeleteConfirm, TxtNull, COLOUR_STATUS);
1386 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)mmi_fv_delete_cb, FOREVER, KEY_LEFT |KEY_RIGHT|KEY_CLEAR|KEY_HUP);
1387 info_dialog (win, &display_info);
1388
1389 }
1390 return MFW_EVENT_CONSUMED;
1391
1392 }
1393
1394
1395 /*******************************************************************************
1396
1397 $Function: mmi_fv_delete_cb
1398
1399 $Description: Exec callback function for the delete window
1400
1401
1402 $Returns: none
1403
1404 $Arguments: win - current win
1405 Identifier-
1406 reason-
1407
1408 *******************************************************************************/
1409 static void mmi_fv_delete_cb (T_MFW_HND win, USHORT Identifier, SHORT reason)
1410 {
1411 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1412 T_fv_opt * data = (T_fv_opt *)win_data->user;
1413 int status;
1414
1415 TRACE_FUNCTION ("mmi_fv_delete_cb()");
1416
1417 switch (reason)
1418 {
1419 case INFO_KCD_LEFT:
1420 TRACE_EVENT("file has been left");
1421
1422 //Delete the selected file from FFS.
1423 status=mmi_fv_delete_jpeg_file((UBYTE)fv_menu_data.fv_list_idx);
1424 if(status>0)
1425 {
1426 mmi_fv_test_show_info(0, TxtNull,TxtNull,TxtDeleted, TxtNull, NULL);
1427 }
1428 SEND_EVENT(data->parent, FV_INIT, Identifier, NULL);
1429 break;
1430 case INFO_KCD_RIGHT:
1431 case INFO_KCD_HUP:
1432 TRACE_EVENT("file has been back");
1433 break;
1434 default:
1435 break;
1436 }
1437 mmi_fv_opt_destroy(fv_optwin);
1438 }
1439
1440 /*******************************************************************************
1441
1442 $Function: mmi_fv_read_jpeg_file
1443
1444 $Description: reads the contents of the file into the buffer .
1445 $Returns: Status
1446
1447 $Arguments:index: Index of the file to be read from FFS.
1448
1449 *******************************************************************************/
1450 GLOBAL int mmi_fv_read_jpeg_file(UBYTE index)
1451 {
1452 T_FFS_FD file_handle = 0;
1453 SHORT readStatus = 1;
1454 //Aug 31, 2005 REF: SPR 34050 xdeepadh
1455 //The filename will have the full path details
1456 char file_name[FV_DIR_PATH_LENGTH];
1457
1458
1459 TRACE_FUNCTION ("mmi_fv_read_jpeg_file()");
1460
1461 strcpy((char*)file_name,FV_DIR_NAME);
1462 strcat((char*)file_name, (const char*)jpegFiles[index]);
1463
1464 TRACE_EVENT_P1("The selected file = %s",jpegFiles[index]);
1465
1466 file_handle = ffs_open(file_name,FFS_O_RDONLY);
1467 if(file_handle <0)
1468 {
1469 readStatus = -1;
1470 mmi_fv_test_show_info(0,TxtNull,TxtNull, TxtFileNotLoaded, TxtNull, NULL);
1471 }
1472 else
1473 {
1474 UINT16 Ffs_stat;
1475 struct stat_s stat;
1476 Ffs_stat = ffs_stat(file_name,&stat);
1477
1478 TRACE_EVENT_P1("read jpg size: %d", stat.size);
1479 if (Ffs_stat != 0)
1480 TRACE_EVENT_P1("read jpg size: %d", stat.size);
1481 if(stat.size >= FV_MAX_JPEG_SIZE )
1482 {
1483 TRACE_EVENT_P1("File zise too big: %d", stat.size);
1484 readStatus = -1;
1485 //Aug 30, 2005 REF:SPR 34049 xdeepadh
1486 //Close the file handle
1487 ffs_close(file_handle);
1488 return readStatus;
1489 }
1490 memset(jpeg_test_array,0,FV_MAX_JPEG_SIZE);
1491 Ffs_stat = ffs_read(file_handle, (UBYTE *)jpeg_test_array, stat.size);
1492 TRACE_EVENT_P1("read jpg file size: %d", Ffs_stat);
1493 ffs_close(file_handle);
1494 }
1495 return readStatus;
1496 }
1497
1498 /*******************************************************************************
1499
1500 $Function: mmi_fv_delete_jpeg_file
1501
1502 $Description: delete the selected file from FFS.
1503 $Returns:Status
1504
1505 $Arguments: index: Index of the file to be read from FFS.
1506
1507 *******************************************************************************/
1508 GLOBAL int mmi_fv_delete_jpeg_file(UBYTE index)
1509 {
1510 //Aug 31, 2005 REF: SPR 34050 xdeepadh
1511 //The filename will have the full path details
1512 char file_name[FV_DIR_PATH_LENGTH];
1513 T_FFS_RET status;
1514
1515 TRACE_FUNCTION ("mmi_fv_delete_jpeg_file()");
1516
1517 strcpy((char*)file_name,FV_DIR_NAME);
1518 strcat((char*)file_name, (const char*)jpegFiles[index]);
1519
1520 TRACE_EVENT_P1("The selected file = %s",jpegFiles[index]);
1521 TRACE_EVENT_P1("The deleted file = %s",file_name);
1522
1523 status = ffs_remove(file_name);
1524 if (status == EFFS_OK)
1525 {
1526 //Populate the list again
1527 file_count = 0;
1528 mmi_fv_init(&file_count);
1529 }
1530 return status;
1531 }
1532
1533
1534
1535 /*******************************************************************************
1536
1537 $Function: mmi_fv_display_image
1538
1539 $Description: The decoded and color converted image is displayed onto the screen.
1540
1541 $Returns:Status
1542
1543 $Arguments:None
1544
1545 *******************************************************************************/
1546
1547 GLOBAL int mmi_fv_display_image()
1548 {
1549 UBYTE status = 0;
1550 TRACE_FUNCTION("mmi_fv_display_image()");
1551
1552 status = mfw_fv_decode_image(jpeg_test_array,sizeof(jpeg_test_array));
1553 if(status)
1554 {
1555 TRACE_FUNCTION("mmi_fv_display_image()--OK");
1556 //return MFW_EVENT_CONSUMED;
1557 }
1558 else
1559 {
1560 TRACE_FUNCTION("mmi_fv_display_image()--Fail");
1561 //return MFW_EVENT_REJECTED;
1562 }
1563
1564 return MFW_EVENT_CONSUMED;
1565
1566 }
1567
1568 /*******************************************************************************
1569
1570 $Function: mmi_fv_reame_edit
1571
1572 $Description: This function is called when the user press rename .
1573
1574 $Returns: Execution status
1575
1576 $Arguments: m - menu handler
1577 i - Menu item selected
1578
1579 *******************************************************************************/
1580 GLOBAL int mmi_fv_reame_edit(MfwMnu* m, MfwMnuItem* i)
1581 {
1582 T_MFW_HND win = mfw_parent(mfw_header());
1583 //T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1584 T_MFW_HND win_temp;
1585 //T_FV_Editor_Data * data = (T_FV_Editor_Data *)(win_data->user);
1586
1587 TRACE_FUNCTION ("mmi_fv_reame_edit()");
1588
1589 win_temp = mmi_fv_editor_create(win);
1590
1591 if (win_temp != NULL)
1592 {
1593 SEND_EVENT(win_temp, FV_INIT, 0, (void *)NULL);
1594 }
1595 else
1596 {
1597 TRACE_FUNCTION ("mmi_fv_reame_edit() : Unable to create Editor Win!");
1598 }
1599 return MFW_EVENT_CONSUMED;
1600 }
1601
1602 /*******************************************************************************
1603
1604 $Function: mmi_fv_editor_create
1605
1606 $Description: Create a window for renaming the image file name
1607
1608 $Returns: window handle
1609
1610 $Arguments: parent - parent window.
1611
1612 *******************************************************************************/
1613
1614
1615 T_MFW_HND mmi_fv_editor_create(T_MFW_HND parent)
1616 {
1617 T_FV_Editor_Data *data;
1618 T_MFW_WIN * win;
1619
1620 TRACE_FUNCTION ("mmi_fv_editor_create");
1621
1622 data = (T_FV_Editor_Data *)mfwAlloc((U16)sizeof(T_FV_Editor_Data));
1623
1624 if (data == NULL)
1625 return data;
1626
1627 data->win = winCreate(parent, 0, E_WIN_VISIBLE, NULL);
1628
1629 if (data->win == NULL)
1630 {
1631 /*
1632 ** Failed to start : Free Memory, and exit
1633 */
1634 mfwFree((U8 *)data, (U16)sizeof(T_FV_Editor_Data));
1635 data = NULL;
1636 return data;
1637 }
1638 else
1639 {
1640 /*
1641 ** Setup the Dialog control functions
1642 */
1643 data->mmi_control.dialog = (T_DIALOG_FUNC)mmi_fv_editor_cntrl;
1644 data->mmi_control.data = data;
1645
1646 win = ((T_MFW_HDR *)data->win)->data;
1647 win->user = (void *)data;
1648 }
1649
1650 return data->win;
1651
1652 }
1653
1654 /*******************************************************************************
1655
1656 $Function: mmi_fv_editor_cntrl
1657
1658 $Description: Exec callback function for the rename window
1659
1660 $Returns: none
1661
1662 $Arguments: win - current window
1663 event - event id
1664 value - unique id
1665 parameter - optional data.
1666
1667 *******************************************************************************/
1668 void mmi_fv_editor_cntrl (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
1669 {
1670 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1671 T_FV_Editor_Data * data = (T_FV_Editor_Data *)win_data->user;
1672 T_AUI_EDITOR_DATA editor_data;
1673 //Aug 31, 2005 REF: SPR 34050 xdeepadh
1674 //The filename will have the full path details
1675 char new_filename[FV_DIR_PATH_LENGTH];
1676 char selected_file[FV_DIR_PATH_LENGTH];
1677 int status = 0;
1678
1679 switch (event)
1680 {
1681 case FV_INIT:
1682 #ifdef NEW_EDITOR
1683 //Clear the editor buffer
1684 memset(&editor_data,'\0',sizeof(editor_data));
1685 // Get the name from FFS
1686 TRACE_EVENT_P1("The file to be renamed file = %s",jpegFiles[fv_menu_data.fv_list_idx]);
1687 strcpy((char *)data->fv_buffer, (const char*)jpegFiles[fv_menu_data.fv_list_idx]);
1688
1689 /*
1690 ** Initialise the editor
1691 */
1692 AUI_edit_SetDefault(&editor_data);
1693 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, data->fv_buffer, FV_FILE_NAME_LENGTH);
1694 AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtDelete, TxtRename, NULL);
1695 AUI_edit_SetAltTextStr(&editor_data, 1, TxtNull, TRUE, TxtSoftBack);
1696 AUI_edit_SetEvents(&editor_data, 0, TRUE, FOREVER, (T_AUI_EDIT_CB)mmi_rename_editor_cb);
1697 data->fv_win_editor = AUI_edit_Start(data->win, &editor_data);
1698 #endif
1699 break;
1700
1701 case FV_EDITOR_CANCEL:
1702 /*
1703 ** The editor will have been destroyed. Reset the Window handler
1704 */
1705 data->fv_win_editor = NULL;
1706 /*
1707 ** Destroy the editor Window
1708 */
1709 TRACE_FUNCTION ("mmi_fv_editor_cntrl cancel");
1710 mmi_fv_editor_destroy(data->win);
1711 mmi_fv_opt_destroy(fv_optwin);
1712 break;
1713
1714 case FV_EDITOR_ERROR:
1715 //Aug 31, 2005 REF: SPR 34050 xdeepadh
1716 //Display the error message to the user
1717 mmi_fv_test_show_info(0, TxtNull,TxtNull,TxtNoExtension, TxtNull, NULL);
1718 /*
1719 ** The editor will have been destroyed. Reset the Window handler
1720 */
1721 data->fv_win_editor = NULL;
1722 /*
1723 ** Destroy the editor Window
1724 */
1725 TRACE_FUNCTION ("mmi_fv_editor_cntrl cancel");
1726 mmi_fv_editor_destroy(data->win);
1727 mmi_fv_opt_destroy(fv_optwin);
1728 break;
1729
1730 case FV_EDITOR_SELECT:
1731 //copy the file name from the editor
1732 strcpy(new_filename,FV_DIR_NAME);
1733 strcat(new_filename,(char *)data->fv_buffer);
1734 TRACE_EVENT_P1("new_filename %s",new_filename);
1735
1736 strcpy(selected_file,FV_DIR_NAME);
1737 strcat(selected_file,(char*)jpegFiles[fv_menu_data.fv_list_idx]);
1738 TRACE_EVENT_P1("selected_file %s",selected_file);
1739
1740 // Rename the file in FFS.
1741 status = ffs_rename(selected_file,new_filename);
1742
1743 TRACE_EVENT_P1("status is %d",status);
1744 //Jan 03, 2006 REF: SPR OMAPS00060036 xdeepadh
1745 //While renaming the file,if the name already exists, display a proper error message.
1746 switch(status)
1747 {
1748
1749 case EFFS_OK:
1750 //Populate the list again
1751 file_count = 0;
1752 mmi_fv_init(&file_count);
1753 break;
1754
1755 case EFFS_EXISTS:
1756 mmi_fv_test_show_info(0, TxtNull,TxtNull,TxtFileExists, TxtNull, NULL);
1757 break;
1758 default:
1759 //Display the error message to the user
1760 mmi_fv_test_show_info(0, TxtNull,TxtNull,TxtWrongFilename, TxtNull, NULL);
1761 }
1762
1763 /*
1764 ** Destroy the Editor Window
1765 */
1766 mmi_fv_editor_destroy(data->win);
1767 mmi_fv_opt_destroy(fv_optwin);
1768
1769 break;
1770
1771 default:
1772 TRACE_FUNCTION ("mmi_fv_editor_cntrl(), Unexpected Event!");
1773 break;
1774 }
1775
1776
1777 }
1778
1779
1780 /*******************************************************************************
1781
1782 $Function: mmi_fv_editor_destroy
1783
1784 $Description: Destroy the rename editor window
1785
1786 $Returns: mfw window handle
1787
1788 $Arguments: own_window - current window
1789
1790 *******************************************************************************/
1791 MfwRes mmi_fv_editor_destroy(T_MFW_HND win)
1792 {
1793 T_MFW_WIN * win_data;
1794 T_FV_Editor_Data * data;
1795
1796 TRACE_FUNCTION ("mmi_fv_editor_destroy");
1797
1798
1799 if (win == NULL)
1800 return MfwResIllHnd;
1801
1802 win_data = ((T_MFW_HDR *) win)->data;
1803 data = (T_FV_Editor_Data *)win_data->user;
1804
1805 /*
1806 ** Destroy the Window
1807 */
1808 win_delete(data->win);
1809
1810 /*
1811 ** Free the dynamically allocated memory
1812 */
1813 mfwFree((U8 *)data, (U16)sizeof(T_FV_Editor_Data));
1814
1815 return MfwResOk;
1816 }
1817
1818 /*******************************************************************************
1819
1820 $Function: mmi_rename_editor_cb
1821
1822 $Description: This function provides the callback functionality to an editor for file viewer
1823
1824 $Returns: None
1825
1826 $Arguments: win - current window
1827 identifier -
1828 reason -
1829 *******************************************************************************/
1830
1831 static void mmi_rename_editor_cb(T_MFW_HND win, USHORT identifier, SHORT reason)
1832 {
1833 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1834 T_FV_Editor_Data* dev_name_data = (T_FV_Editor_Data *)win_data->user;
1835
1836 UBYTE * editor_buffer = NULL;
1837 SHORT max_edit_size = 0;
1838 T_MFW_HND editor_win;
1839 T_MFW_HND parent;
1840 char * fileExt;
1841
1842 TRACE_FUNCTION ("mmi_rename_editor_cb()");
1843
1844 editor_buffer = dev_name_data->fv_buffer;
1845 max_edit_size = FV_FILE_NAME_LENGTH - 1;
1846 editor_win = dev_name_data->fv_win_editor;
1847 parent = dev_name_data->win;
1848
1849 switch (reason)
1850 {
1851 case INFO_KCD_LEFT:
1852 {
1853 /*
1854 ** If there is no string entered, treat this as if it was a "Cancel"
1855 */
1856 if (editor_buffer[0] == NULL)
1857 {
1858 /*
1859 ** Send a "Cancel" to the window
1860 */
1861 SEND_EVENT(parent, FV_EDITOR_CANCEL, identifier, NULL);
1862 }
1863 else
1864 {
1865 //If the file extn is not jpg, send cancel event
1866 fileExt = (char *)mmi_fv_GetExtension((char *)editor_buffer);
1867 if ( (strcmp(fileExt, "jpg") != 0))
1868 {
1869 //Aug 31, 2005 REF: SPR 34050 xdeepadh
1870 /*
1871 ** Send a "Error" to the window
1872 */
1873 SEND_EVENT(parent, FV_EDITOR_ERROR, identifier, NULL);
1874 }
1875 else
1876 {
1877 /*
1878 ** Send a "Select" to the window
1879 */
1880 SEND_EVENT(parent, FV_EDITOR_SELECT, identifier, NULL);
1881 }
1882 }
1883 }
1884 break;
1885
1886 case INFO_KCD_RIGHT:
1887 if (strlen((char *)editor_buffer) == NULL)
1888 {
1889
1890 /*
1891 ** Send a "Cancel" to the window
1892 */
1893 SEND_EVENT(parent, FV_EDITOR_CANCEL, identifier, NULL);
1894 }
1895 break;
1896
1897 case INFO_KCD_HUP:
1898 /*
1899 ** Set the buffer to NULLS
1900 */
1901 memset(editor_buffer, NULL, max_edit_size);
1902
1903 /*
1904 ** Send a "Cancel" to the window
1905 */
1906 SEND_EVENT(parent, FV_EDITOR_CANCEL, identifier, NULL);
1907 break;
1908
1909 default:
1910 /* otherwise no action to be performed
1911 */
1912 break;
1913 }
1914 }
1915
1916 /*******************************************************************************
1917
1918 $Function: mmi_fv_rotate_image_start
1919
1920 $Description: Create window for displaying the rotated image.
1921
1922 $Returns: none
1923
1924 $Arguments: m - menu handler
1925 i - menu item selected.
1926 *******************************************************************************/
1927 int mmi_fv_rotate_image_start(T_MFW_HND parent)
1928 {
1929 T_MFW_HND win;
1930 win = (T_MFW_HND)mmi_fv_rotate_image_create((MfwHnd)parent);
1931 TRACE_FUNCTION ("mmi_fv_rotate_image_start");
1932 if (win NEQ NULL)
1933 {
1934 SEND_EVENT(win,FV_INIT,FV_OPT_ID,0);
1935 }
1936
1937 return MFW_EVENT_CONSUMED;
1938 }
1939
1940
1941 /*******************************************************************************
1942
1943 $Function: mmi_fv_rotate_image_create
1944
1945 $Description: Create a window for rotating the image.
1946
1947 $Returns: window handle
1948
1949 $Arguments: parent_window - parent window.
1950
1951 *******************************************************************************/
1952
1953 static T_MFW_HND mmi_fv_rotate_image_create(MfwHnd parent_window)
1954 {
1955 T_fv_opt* data = (T_fv_opt *)ALLOC_MEMORY (sizeof (T_fv_opt));
1956 T_MFW_WIN * win;
1957
1958 TRACE_FUNCTION ("mmi_fv_rotate_image_create()");
1959
1960 // Create window handler
1961 data->win = win_create (parent_window, 0, E_WIN_VISIBLE,(MfwCb)mmi_fv_rotate_win_cb);
1962 if (data->win EQ NULL)
1963 {
1964 return NULL;
1965 }
1966
1967 // connect the dialog data to the MFW-window
1968 data->mmi_control.dialog = (T_DIALOG_FUNC)mmi_fv_rotate_exec_cb;
1969 data->mmi_control.data = data;
1970 win = ((T_MFW_HDR *)data->win)->data;
1971 win->user = (MfwUserDataPtr)data;
1972 data->parent = parent_window;
1973 //Create keyboard handler
1974 data->kbd = kbd_create (data->win,KEY_ALL,(T_MFW_CB)mmi_fv_rotate_kbd_cb);
1975 winShow(data->win);
1976 return data->win;
1977 }
1978
1979
1980 /*******************************************************************************
1981
1982 $Function: mmi_fv_rotate_exec_cb
1983
1984 $Description: Callback handler for events sent by the images editor
1985
1986 $Returns: none
1987
1988 $Arguments: win - current window
1989 event - event id
1990 parameter - optional data.
1991 *******************************************************************************/
1992
1993 static void mmi_fv_rotate_exec_cb(T_MFW_HND win, USHORT event, void *parameter)
1994 {
1995 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1996 T_fv_opt * data = (T_fv_opt *)win_data->user;
1997 int status;
1998
1999 TRACE_FUNCTION ("mmi_fv_rotate_exec_cb()");
2000
2001 switch (event)
2002 {
2003 case FV_INIT:
2004 TRACE_EVENT("init");
2005 status = mfw_fv_rotate_image();
2006 if(!status)
2007 {
2008 mmi_fv_test_show_info(0,TxtNull,TxtNull, TxtError, TxtNull, NULL);
2009 }
2010 break;
2011
2012 case FV_RETURN:
2013
2014 break;
2015 default:
2016 TRACE_EVENT("Err: Default");
2017 return;
2018 }
2019 }
2020
2021 /*******************************************************************************
2022
2023 $Function: mmi_fv_rotate_win_cb
2024
2025 $Description: Window callback function for the rotate window
2026
2027 $Returns: execution status
2028
2029 $Arguments: e - event id
2030 w - window handle
2031 *******************************************************************************/
2032
2033 static int mmi_fv_rotate_win_cb (MfwEvt e, MfwWin w)
2034 {
2035 TRACE_FUNCTION ("mmi_fv_rotate_win_cb()");
2036
2037 switch (e)
2038 {
2039 case MfwWinVisible: /* window is visible */
2040 dspl_ClearAll();
2041 displaySoftKeys(TxtNull,TxtSoftBack);
2042 break;
2043 case MfwWinFocussed: /* input focus / selected */
2044 case MfwWinDelete: /* window will be deleted */
2045 default:
2046 return MFW_EVENT_REJECTED;
2047 }
2048 return MFW_EVENT_CONSUMED;
2049 }
2050
2051 /*******************************************************************************
2052
2053 $Function: mmi_fv_rotate_kbd_cb
2054
2055 $Description: Exec callback function for the rotate window
2056
2057 $Returns: execution status
2058
2059 $Arguments: e - event id
2060 k - keyboard info
2061 *******************************************************************************/
2062
2063 static int mmi_fv_rotate_kbd_cb (MfwEvt e, MfwKbd *k)
2064 {
2065 T_MFW_HND win = mfwParent(mfw_header());
2066 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
2067 T_fv_opt * data = (T_fv_opt *)win_data->user;
2068
2069 TRACE_FUNCTION ("mmi_fv_rotate_kbd_cb()");
2070
2071 switch (k->code)
2072 {
2073 case KCD_LEFT:
2074 TRACE_EVENT("mmi_fv_rotate_kbd_cb,INFO_KCD_LEFT ");
2075 break;
2076
2077 case KCD_RIGHT:
2078 case KCD_HUP:
2079 TRACE_EVENT("mmi_fv_rotate_kbd_cb,INFO_KCD_RIGHT ");
2080 mmi_fv_opt_destroy(data->win);
2081 break;
2082 default:
2083
2084 break;
2085
2086 }
2087 return MFW_EVENT_CONSUMED;
2088 }
2089
2090 /*******************************************************************************
2091
2092 $Function: mmi_fv_zoom_image_start
2093
2094 $Description: Create window for displaying the zoomed image.
2095
2096 $Returns: none
2097
2098 $Arguments: m - menu handler
2099 i - menu item selected.
2100 *******************************************************************************/
2101 int mmi_fv_zoom_image_start(T_MFW_HND parent)
2102 {
2103 T_MFW_HND win;
2104 win = (T_MFW_HND)mmi_fv_zoom_image_create((MfwHnd)parent);
2105 TRACE_FUNCTION ("mmi_fv_zoom_image_start");
2106 if (win NEQ NULL)
2107 {
2108 SEND_EVENT(win,FV_INIT,FV_OPT_ID,0);
2109 }
2110 return MFW_EVENT_CONSUMED;
2111
2112 }
2113
2114 /*******************************************************************************
2115
2116 $Function: mmi_fv_zoom_image_create
2117
2118 $Description: Create a window for zooming the image.
2119
2120 $Returns: window handle
2121
2122 $Arguments: parent_window - parent window.
2123
2124 *******************************************************************************/
2125
2126 static T_MFW_HND mmi_fv_zoom_image_create(MfwHnd parent_window)
2127 {
2128 T_fv_opt* data = (T_fv_opt *)ALLOC_MEMORY (sizeof (T_fv_opt));
2129 T_MFW_WIN * win;
2130
2131 TRACE_FUNCTION ("mmi_fv_zoom_image_create()");
2132
2133 // Create window handler
2134 data->win = win_create (parent_window, 0, E_WIN_VISIBLE,(MfwCb)mmi_fv_zoom_win_cb);
2135 if (data->win EQ NULL)
2136 {
2137 return NULL;
2138 }
2139
2140 // connect the dialog data to the MFW-window
2141 data->mmi_control.dialog = (T_DIALOG_FUNC)mmi_fv_zoom_exec_cb;
2142 data->mmi_control.data = data;
2143 win = ((T_MFW_HDR *)data->win)->data;
2144 win->user = (MfwUserDataPtr)data;
2145 data->parent = parent_window;
2146 //Create keyboard handler
2147 data->kbd = kbd_create (data->win,KEY_ALL,(T_MFW_CB)mmi_fv_zoom_kbd_cb);
2148 winShow(data->win);
2149 return data->win;
2150 }
2151
2152
2153 /*******************************************************************************
2154
2155 $Function: mmi_fv_zoom_exec_cb
2156
2157 $Description: Callback handler for events sent by the images editor
2158
2159 $Returns: none
2160
2161 $Arguments: win - current window
2162 event - event id
2163 parameter - optional data.
2164 *******************************************************************************/
2165
2166 static void mmi_fv_zoom_exec_cb(T_MFW_HND win, USHORT event, void *parameter)
2167 {
2168 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
2169 T_fv_opt * data = (T_fv_opt *)win_data->user;
2170 int status;
2171
2172 TRACE_FUNCTION ("mmi_fv_zoom_exec_cb()");
2173
2174 switch (event)
2175 {
2176 case FV_INIT:
2177 TRACE_EVENT("init");
2178 status = mfw_fv_zoom_image();
2179 if(!status)
2180 {
2181 mmi_fv_test_show_info(0,TxtNull,TxtNull, TxtError, TxtNull, NULL);
2182 }
2183
2184 break;
2185
2186 case FV_RETURN:
2187
2188 break;
2189 default:
2190 TRACE_EVENT("Err: Default");
2191 return;
2192 }
2193 }
2194
2195 /*******************************************************************************
2196
2197 $Function: mmi_fv_zoom_win_cb
2198
2199 $Description: Window callback function for the Option window
2200
2201 $Returns: execution status
2202
2203 $Arguments: e - event id
2204 w - window handle
2205 *******************************************************************************/
2206
2207 static int mmi_fv_zoom_win_cb (MfwEvt e, MfwWin w)
2208 {
2209 TRACE_FUNCTION ("mmi_fv_zoom_win_cb()");
2210
2211 switch (e)
2212 {
2213 case MfwWinVisible: /* window is visible */
2214 dspl_ClearAll();
2215 displaySoftKeys(TxtNull,TxtSoftBack);
2216 break;
2217 case MfwWinFocussed: /* input focus / selected */
2218 case MfwWinDelete: /* window will be deleted */
2219 default:
2220 return MFW_EVENT_REJECTED;
2221 }
2222 return MFW_EVENT_CONSUMED;
2223 }
2224
2225 /*******************************************************************************
2226
2227 $Function: mmi_fv_zoom_kbd_cb
2228
2229 $Description: Exec callback function for the zoom window
2230
2231 $Returns: execution status
2232
2233 $Arguments: e - event id
2234 k - keyboard info
2235 *******************************************************************************/
2236
2237 static int mmi_fv_zoom_kbd_cb (MfwEvt e, MfwKbd *k)
2238 {
2239 T_MFW_HND win = mfwParent(mfw_header());
2240 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
2241 T_fv_opt * data = (T_fv_opt *)win_data->user;
2242
2243 TRACE_FUNCTION ("mmi_fv_zoom_kbd_cb()");
2244
2245 switch (k->code)
2246 {
2247 case KCD_LEFT:
2248 TRACE_EVENT("mmi_fv_zoom_kbd_cb,INFO_KCD_LEFT ");
2249 break;
2250
2251 case KCD_RIGHT:
2252 case KCD_HUP:
2253 TRACE_EVENT("mmi_fv_zoom_kbd_cb,INFO_KCD_RIGHT ");
2254 mmi_fv_opt_destroy(data->win);
2255 break;
2256 default:
2257
2258 break;
2259
2260 }
2261 return MFW_EVENT_CONSUMED;
2262 }
2263
2264