comparison src/ui3/bmi/mmiBtipsOppc.c @ 420:e8ddbb0837ed

src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:09:00 +0000
parents
children
comparison
equal deleted inserted replaced
419:59143cd42ec7 420:e8ddbb0837ed
1 /* =========================================================
2 * Texas Instruments OMAP(TM) Platform Software
3 * (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
4 *
5 * Use of this software is controlled by the terms and conditions found
6 * in the license agreement under which this software has been supplied.
7 * ========================================================== */
8 /*
9 $Project name: Basic Bluetooth MMI
10 $Project code:
11 $Module: Bluetooth BMG APPlication
12 $File: MmiBtipsBmg.c
13 $Revision: 1.0
14 $Author: Texas Instruments
15 $Date: 26/06/07
16
17 ********************************************************************************
18
19 Description:
20
21 This module provides the BTIPS BMG APPlication functionality.
22
23 ********************************************************************************
24 $History: MmiBtipsBmg.c
25
26 26/06/07 Sasken original version
27
28 $End
29
30 *******************************************************************************/
31
32
33
34
35 /*******************************************************************************
36
37 Include files
38
39 *******************************************************************************/
40
41 #define ENTITY_MFW
42
43 #include <string.h>
44
45 /* BTIPS Includes */
46 #include "me.h"
47
48
49 #if defined (NEW_FRAME)
50
51 #include "typedefs.h"
52 #include "vsi.h"
53 #include "pei.h"
54 #include "custom.h"
55 #include "gsm.h"
56 #include "prim.h"
57
58 #else
59
60 #include "STDDEFS.H"
61 #include "custom.h"
62 #include "gsm.h"
63 #include "vsi.h"
64
65 #endif
66
67 #include "mfw_mfw.h"
68 #include "mfw_win.h"
69 #include "mfw_icn.h" /* included for mfw_mnu.h */
70 #include "mfw_mnu.h"
71 #include "mfw_tim.h"
72 #include "mfw_kbd.h"
73 #include "mfw_sat.h" /* included for MmiDummy.h, included for MmiMenu.h */
74 #include "MmiBlkLangDB.h"
75 #include "mmiColours.h"
76 #include "MmiDialogs.h"
77 #include "MmiDummy.h" /* included for MmiMenu.h */
78 #include "MmiLists.h"
79 #include "MmiMenu.h"
80 #include "MmiSoftKeys.h"
81 #include "AUIEditor.h"
82 #include "MmiMain.h"
83 #include "Mmiicons.h"
84 #include "MmiWindow.h"
85 #include "MmiCall.h"
86 #include "mmiBookShared.h"
87
88 #include "mmiBtips.h"
89 #include "mfw_btips.h"
90 #include "mmiBtipsOppc.h"
91 #include "mfw_BtipsOppc.h"
92 #include "mfw_BtipsBmg.h"
93
94 #ifdef FF_MMI_BTIPS_APP
95
96 #endif
97
98 /*Function Declarations*/
99
100 #define OPPC_MAX_FILES 10
101
102
103 int oppc_files_count;
104 char* oppc_file_names[OPPC_MAX_FILES];
105 #define OPPC_INFO_SCRN_TIMEOUT 1500//Timeout for InfoDialog
106 char push_file_name[256];
107 char pull_file_name[256];
108
109 int mmi_btips_oppcDeviceSearchCallback(BD_ADDR bdAddr);
110 int mmi_btips_oppcPullDeviceSearchCallback(BD_ADDR bdAddr);
111 int mmi_btips_oppcExchangeDeviceSearchCallback(BD_ADDR bdAddr);
112
113 int mmi_btips_oppcPullHandler(MfwMnu* m, MfwMnuItem* i)
114 {
115 TRACE_FUNCTION("mmi_btips_oppcPullHandler");
116 mmi_btips_oppcDeviceSearchWnd(1);
117 }
118
119 int mmi_btips_oppcExchangeHandler(MfwMnu* m, MfwMnuItem* i)
120 {
121 TRACE_FUNCTION("mmi_btips_oppcExchangeHandler");
122 mmi_btips_oppcDeviceSearchWnd(2);
123 }
124
125 int mmi_btips_oppcHandler(MfwMnu* m, MfwMnuItem* i)
126 {
127 T_MFW_HND win;
128 T_MFW_HND parent_win = mfw_parent(mfw_header());
129 int numFiles=0;
130
131 TRACE_FUNCTION ("mmi_btips_oppcHandler");
132 oppc_files_count = OPPC_MAX_FILES;
133 oppc_files_count=mfw_btips_oppcPopulateFiles(oppc_file_names,OPPC_MAX_FILES,
134 BT_DEMO_FOLDER_PATH);
135 TRACE_FUNCTION_P1("oppc_files_count - %d", oppc_files_count);
136 numFiles = mfw_btips_oppcGetNumFiles();
137 mmi_btips_oppcShowInfoDlg(0, TxtMidiFileNotLoaded, TxtNull, NULL);
138 TRACE_EVENT_P1("mmi_btips_oppcHandler: numFiles is %d",numFiles);
139
140 if(numFiles <= 0)
141 {
142 mmi_btips_oppcShowInfoDlg(0, TxtMidiFileNotLoaded, TxtNull, NULL);
143
144 }
145 else
146 {
147 win = mmi_btips_oppcBuildMenu(parent_win);
148 if (win NEQ NULL)
149 {
150 SEND_EVENT (win, BTIPS_OPPC_LIST_INIT, 0, 0);
151 }
152
153 }
154
155 return MFW_EVENT_CONSUMED;
156 }
157
158 /*******************************************************************************
159
160 $Function: mmi_btips_oppcBuildMenu
161
162 $Description: To hold list window
163
164 $Returns: Window handle
165
166 $Arguments:
167 *******************************************************************************/
168
169 static T_MFW_HND mmi_btips_oppcBuildMenu( MfwHnd parent_window)
170 {
171 T_MMI_Btips_Oppc_Win_data * data = (T_MMI_Btips_Oppc_Win_data *)mfwAlloc(sizeof (T_MMI_Btips_Oppc_Win_data));
172 T_MFW_WIN * win;
173
174 TRACE_FUNCTION ("mmi_btips_oppcBuildMenu");
175 /*
176 * Create window handler
177 */
178
179 data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)mmi_btips_oppcListWinCb);
180 if (data->win EQ NULL)
181 {
182 return NULL;
183 }
184
185 TRACE_EVENT("list holder window created: " );
186 /*
187 * connect the dialog data to the MFW-window
188 */
189
190 data->mmi_control.dialog = (T_DIALOG_FUNC)mmi_btips_oppcListWinExecCb;
191 data->mmi_control.data = data;
192 win = ((T_MFW_HDR *)data->win)->data;
193 win->user = (void *)data;
194 data->parent = parent_window;
195 winShow(data->win);
196 /*
197 * return window handle
198 */
199
200 return data->win;
201 }
202
203 /*******************************************************************************
204
205 $Function: mmi_btips_oppcListWinCb
206
207 $Description: Window event handler
208
209 $Returns: MFW_EVENT_REJECTED:
210 MFW_EVENT_CONSUMED:
211
212 $Arguments:
213
214 *******************************************************************************/
215 static int mmi_btips_oppcListWinCb (MfwEvt e, MfwWin *w)
216 {
217 TRACE_FUNCTION ("mmi_btips_oppcListWinCb()");
218 switch (e)
219 {
220 case MfwWinVisible: /* window is visible */
221 break;
222 case MfwWinFocussed: /* input focus / selected */
223 case MfwWinDelete: /* window will be deleted */
224
225 default:
226 return MFW_EVENT_REJECTED;
227 }
228 return MFW_EVENT_CONSUMED;
229 }
230
231 /*******************************************************************************
232
233 $Function: mmi_btips_oppcListWinExecCb
234
235 $Description: Call back function
236
237 $Returns: none
238
239 $Arguments:
240
241 *******************************************************************************/
242 void mmi_btips_oppcListWinExecCb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
243 {
244 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
245 T_MMI_Btips_Oppc_Win_data * data = (T_MMI_Btips_Oppc_Win_data *)win_data->user;
246 int max_file_number;
247 int i;
248
249 ListWinInfo * mnu_data = (ListWinInfo *)parameter;
250
251 TRACE_FUNCTION ("mmi_btips_oppcListWinExecCb()");
252 switch (event)
253 {
254 T_MFW OppcListCreationStatus;
255 case BTIPS_OPPC_LIST_INIT:
256 {
257
258 TRACE_EVENT("mmi_btips_oppcListWinExecCb() Event:E_INIT");
259
260 /* initialization of administrative data */
261
262 data->menu_list_data = (ListMenuData *)ALLOC_MEMORY(sizeof(ListMenuData));
263
264 if(data->menu_list_data == 0)
265 {
266 TRACE_EVENT("Failed memory alloc 1 ");
267 return;
268 }
269
270 max_file_number = mfw_btips_oppcGetNumFiles();
271 //In case no files have been loaded display info message
272 //In case no files have been loaded return info message
273 if(max_file_number == 0)
274 {
275 return;
276 }
277
278
279 data->menu_list_data->List = (T_MFW_MNU_ITEM *)ALLOC_MEMORY( max_file_number * sizeof(T_MFW_MNU_ITEM) );
280
281 if(data->menu_list_data->List == 0)
282 {
283 TRACE_EVENT("Failed memory alloc 2");
284 return;
285 }
286 for (i = 0; i < max_file_number ; i++)
287 {
288 mnuInitDataItem(&data->menu_list_data->List[i]);
289 data->menu_list_data->List[i].flagFunc = item_flag_none;
290 //Display the OPPC file names in the list
291 data->menu_list_data->List[i].str =
292 (char *)mfw_btips_oppcGetFileName(data->oppc_file_count++);
293 }
294
295 data->menu_list_data->ListLength =max_file_number;
296 data->menu_list_data->ListPosition = 1;
297 data->menu_list_data->CursorPosition = 1;
298 data->menu_list_data->SnapshotSize = max_file_number;
299 data->menu_list_data->Font = 0;
300 data->menu_list_data->LeftSoftKey = TxtSoftSelect;
301 data->menu_list_data->RightSoftKey = TxtSoftBack;
302 data->menu_list_data->KeyEvents = KEY_ALL;
303 data->menu_list_data->Reason = 0;
304 data->menu_list_data->Strings = TRUE;
305 data->menu_list_data->Attr = (MfwMnuAttr*)&BtipsOppcList_Attrib;
306 data->menu_list_data->Attr->hdrId = TxtPlayerSelectFile;
307 data->menu_list_data->autoDestroy = FALSE;
308 OppcListCreationStatus =
309 listDisplayListMenu (win, data->menu_list_data,
310 (ListCbFunc)mmi_btips_oppcListMenuCb,0);
311 if (LISTS_OK == OppcListCreationStatus)
312 {
313 #if 0
314 /*If control reached this point then List of files are showed on display*/
315 isMidiListON = TRUE;
316 /*Create one timer and play the file only if that timer expires*/
317 /*Play the first file if user hasn't pressed the up and down for half a second */
318 mfw_player_currently_playing_idx = 0;
319 midiBrowseTimer = timCreate( 0, TIME_HALFSECOND, (MfwCb)midi_test_play_browsing);
320 timStart( midiBrowseTimer );
321 #endif
322 }
323 }
324 break;
325 default:
326 break;
327 }
328
329 }
330
331 /*******************************************************************************
332
333 $Function: midi_mt_menu_list_listmnu_cb
334
335 $Description: destroy lists and menu in case of back softkey or menu exit
336
337 $Returns:
338
339 $Arguments:
340
341 *******************************************************************************/
342 static void mmi_btips_oppcListMenuCb(T_MFW_HND Parent, ListMenuData * ListData)
343 {
344 T_MFW_WIN *win_data = ((T_MFW_HDR *)Parent)->data;
345 T_MMI_Btips_Oppc_Win_data *data = (T_MMI_Btips_Oppc_Win_data *)win_data->user;
346 char* szSelectedFileExt;
347 T_MFW_HND parent_win = mfw_parent(mfw_header());
348 TRACE_FUNCTION ("mmi_btips_oppcListMenuCb()");
349
350 if ((ListData->Reason EQ LISTS_REASON_BACK) ||
351 (ListData->Reason EQ LISTS_REASON_CLEAR) ||
352 (ListData->Reason EQ LISTS_REASON_HANGUP))
353 {
354 /*
355 ** Destroy the window --- Not sure if this is required! ... leave it out for now
356 */
357 listsDestroy(ListData->win);
358
359 /*
360 ** Free the memory set aside for ALL the devices to be listed.
361 */
362 if (data->menu_list_data != NULL)
363 {
364 FREE_MEMORY ((void *)data->menu_list_data->List, (U16)(data->oppc_num_file * sizeof (T_MFW_MNU_ITEM)));
365 FREE_MEMORY ((void *)data->menu_list_data, sizeof (ListMenuData));
366 }
367
368 mmi_btips_oppcListMenuDestroy(data->win);
369 #if 0
370 // June 19, 2006 REF: DRT OMAPS00076378 x0012849
371 /*At this point the MIDI list is destroyed*/
372 isMidiListON = FALSE;
373 /* At this point the play need to be stopped. If user wants the file need to
374 be played while going across menu then 'play' or 'play all' need to be selected */
375 midi_stop_player (NULL, NULL);
376 if (midiBrowseTimer != NULL)
377 {
378 // Delete the timer. It's not required any more.
379 timDelete (midiBrowseTimer);
380 }
381 #endif
382 }
383 else if(ListData->Reason EQ LISTS_REASON_SELECT)
384 {
385 strcpy(push_file_name, OPPC_DEFAULT_PUSH_PULL_DIR);
386 //strcat(push_file_name, ListData->List->str);
387 strcat(push_file_name, ListData->List[ListData->ListPosition].str);
388 mmi_btips_oppcDeviceSearchWnd(0);
389 #if 0
390 szSelectedFileExt = mfw_btips_oppcGetExtension(mfw_btips_oppcGetFileName(ListData->CursorPosition));
391
392 //This was for the Options menu
393 //data->oppc_optionsMenu=(T_MFW_HND)bookMenuStart( parent_win, btipsOppcOptionsMenuAttributes(), 0);
394 if ( (strcmp(szSelectedFileExt, "mp3") == 0))
395 {
396 mmi_btips_oppcDeviceSearchWnd();
397 }
398 else if ( (strcmp(szSelectedFileExt, "pcm") == 0))
399 {
400 mmi_btips_oppcDeviceSearchWnd();
401 }
402 else if ( (strcmp(szSelectedFileExt, "wav") == 0))
403 {
404 mmi_btips_oppcDeviceSearchWnd();
405 }
406 else
407 {
408 //It should never come here
409 }
410 #endif
411
412 #if 0
413 TRACE_EVENT_P1("list position is %d",ListData->ListPosition);
414 mt_menu_data.mt_list_idx = ListData->ListPosition;
415 //call mfw to save selected index
416 mfw_player_save_selected_file_idx(mt_menu_data.mt_list_idx);
417 //display a "file selected" text here
418 mmi_midi_test_show_info(0, TxtMidiFileSelected, TxtNull, NULL);
419 #endif
420 }
421
422 return;
423 }
424
425 /*******************************************************************************
426
427 $Function: mmi_btips_oppcListMenuDestroy
428
429 $Description: destroy menu window
430
431 $Returns:
432
433 $Arguments: window to be destroyed
434
435 *******************************************************************************/
436 static void mmi_btips_oppcListMenuDestroy(MfwHnd window)
437 {
438 T_MFW_WIN * win_data = ((T_MFW_HDR *)window)->data;
439 T_MMI_Btips_Oppc_Win_data * data = (T_MMI_Btips_Oppc_Win_data *)win_data->user;
440
441 TRACE_FUNCTION ("mmi_btips_oppcListMenuDestroy");
442
443 if (window == NULL)
444 {
445 return;
446 }
447
448 if (data)
449 {
450 win_delete(data->win);
451
452 /*
453 ** Free Memory
454 */
455 mfwFree((void *)data, sizeof (T_MMI_Btips_Oppc_Win_data));
456 }
457 }
458 /*******************************************************************************
459
460 $Function: mmi_btips_oppcShowInfoDlg
461
462 $Description: Display the Dialog
463
464 $Returns:
465
466 $Arguments:
467
468 *******************************************************************************/
469 static MfwHnd mmi_btips_oppcShowInfoDlg(T_MFW_HND parent, int str1, int str2, T_VOID_FUNC callback)
470 {
471 T_DISPLAY_DATA display_info;
472
473 TRACE_FUNCTION ("mmi_btips_oppcShowInfoDlg()");
474
475 /*
476 ** Create a timed dialog to display the Message "Failed"
477 */
478 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, str1, str2, COLOUR_STATUS);
479 dlg_initDisplayData_events( &display_info, callback, OPPC_INFO_SCRN_TIMEOUT, KEY_LEFT | KEY_CLEAR | KEY_HUP);
480
481 return info_dialog(parent, &display_info);
482 }
483
484 int mmi_btips_oppcDeviceSearchWnd(int type)
485 {
486 T_MFW_HND parent_win = mfwParent(mfw_header());
487 //mmi_btips_bmg_devices_win_create(parent_win, BTIPS_GENERIC_DEVICE_SEARCH, NULL);
488 switch (type)
489 {
490 case 0:
491 mmi_btips_bmg_devices_win_create(parent_win, BTIPS_OPP_DEVICE_SEARCH, mmi_btips_oppcDeviceSearchCallback);
492 break;
493
494 case 1:
495 mmi_btips_bmg_devices_win_create(parent_win, BTIPS_OPP_DEVICE_SEARCH, mmi_btips_oppcPullDeviceSearchCallback);
496 break;
497
498 case 2:
499 mmi_btips_bmg_devices_win_create(parent_win, BTIPS_OPP_DEVICE_SEARCH, mmi_btips_oppcExchangeDeviceSearchCallback);
500 break;
501 }
502
503 return MFW_EVENT_CONSUMED;
504 }
505 int mmi_btips_oppcDeviceSearchCallback(BD_ADDR bdAddr)
506 {
507 static char szDevName[128];
508 mfw_btips_bmgGetDeviceName(&bdAddr, szDevName);
509 TRACE_FUNCTION_P1("mmi_btips_oppcDeviceSearchCallback with Dev Name %s", szDevName);
510 mmi_btips_app_show_text(0, szDevName, "Selected Device",NULL);
511 //mmi_btips_app_show_text(0, szBdAddr, TxtNull, NULL);
512 //OPPCA_Connect(&bdAddr);
513 mfw_btips_oppcEncapsulatePush(push_file_name, &bdAddr);
514 return MFW_EVENT_CONSUMED;
515 }
516 int mmi_btips_oppcPullDeviceSearchCallback(BD_ADDR bdAddr)
517 {
518 static char szDevName[128];
519 mfw_btips_bmgGetDeviceName(&bdAddr, szDevName);
520 TRACE_FUNCTION_P1("mmi_btips_oppcDeviceSearchCallback with Dev Name %s", szDevName);
521 mmi_btips_app_show_text(0, szDevName, "Selected Device",NULL);
522 //mmi_btips_app_show_text(0, szBdAddr, TxtNull, NULL);
523 //OPPCA_Connect(&bdAddr);
524 strcpy(pull_file_name, OPPC_DEFAULT_PUSH_PULL_DIR);
525 strcat(pull_file_name, szDevName);
526 strcat(pull_file_name, OPPC_VCF_EXT);
527 mfw_btips_oppcEncapsulatePull(pull_file_name, &bdAddr);
528 return MFW_EVENT_CONSUMED;
529 }
530
531 int mmi_btips_oppcExchangeDeviceSearchCallback(BD_ADDR bdAddr)
532 {
533 static char szDevName[128];
534 mfw_btips_bmgGetDeviceName(&bdAddr, szDevName);
535 TRACE_FUNCTION_P1("mmi_btips_oppcDeviceSearchCallback with Dev Name %s", szDevName);
536 mmi_btips_app_show_text(0, szDevName, "Selected Device",NULL);
537 //mmi_btips_app_show_text(0, szBdAddr, TxtNull, NULL);
538 //OPPCA_Connect(&bdAddr);
539 strcpy(push_file_name, OPPC_DEFAULT_PUSH_CARD);
540 strcpy(pull_file_name, OPPC_DEFAULT_PUSH_PULL_DIR);
541 strcat(pull_file_name, szDevName);
542 strcat(pull_file_name, OPPC_VCF_EXT);
543 mfw_btips_oppcEncapsulateExchange(push_file_name, pull_file_name, &bdAddr);
544 return MFW_EVENT_CONSUMED;
545 }
546
547