MMI.cpp
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:52k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  *  MMI.cpp
  40.  *
  41.  * Project:
  42.  * --------
  43.  *  MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  WinMain() for PC simulator
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  * -------
  53.  *                      
  54.  *============================================================================
  55.  *             HISTORY
  56.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  57.  *------------------------------------------------------------------------------
  58.  * removed!
  59.  *
  60.  * removed!
  61.  * removed!
  62.  * removed!
  63.  *
  64.  * removed!
  65.  * removed!
  66.  * removed!
  67.  *
  68.  * removed!
  69.  * removed!
  70.  * removed!
  71.  *
  72.  * removed!
  73.  * removed!
  74.  * removed!
  75.  * removed!
  76.  *
  77.  * removed!
  78.  * removed!
  79.  * removed!
  80.  *
  81.  * removed!
  82.  * removed!
  83.  * removed!
  84.  * removed!
  85.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  *------------------------------------------------------------------------------
  136.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  137.  *============================================================================
  138.  ****************************************************************************/
  139. #ifndef _MMI_CPP
  140. #define _MMI_CPP
  141. #ifdef MMI_ON_WIN32
  142. #include "stdafx.h"
  143. #include "resource.h"
  144. #include "windows.h"
  145. #include "MMI_features.h"
  146. #include <mmsystem.h>
  147. #include "MMI.h"
  148. #include "pixteldatatypes.h"
  149. #include "QueueGprot.h"
  150. #include "KeyBrd.h"
  151. /* #include "taskinit.h" new customizer */
  152. #include "DCMLHandler.h" /* main symbols */
  153. #include "BUildCfg.h"
  154. #include "CustDataRes.h"
  155. #include "CustDataProts.h"
  156. #include "Custresdef.h"
  157. #include "GlobalConstants.h" /* KEY_INVALID */
  158. #include "FontDCL.h"
  159. #include "FontRes.h"
  160. #include "ProtocolEvents.h"
  161. #include <assert.h>
  162. extern "C"
  163.   #include "CustThemesRes.h"
  164.   #include "AudioInc.h"
  165.   #include "taskinit.h"
  166. }
  167. #ifndef __CUSTOMER_LEVEL_1_RELEASE__
  168. #include "NWSimEngine.h"
  169. #endif
  170. /***************************************************************************** 
  171. * Define
  172. *****************************************************************************/
  173. #define WM_REFRESH_MMI (10006)
  174. #define WM_CLOSE_CUSTOMIZE_ENG (10007)
  175. /* used for skin loader */
  176. #define SKIN_128x128 (0)
  177. #define SKIN_128x160 (1)
  178. #define SKIN_176x220 (2)
  179. #define SKIN_240x320 (3)
  180. #define BUFFER_LENGTH (256)
  181. #define PATH_FOR_128x128 "../Skins/128x128"
  182. #define PATH_FOR_128x160 "../Skins/128x160"
  183. #define PATH_FOR_176x220 "../Skins/176x220"
  184. #define PATH_FOR_240x320 "../Skins/240x320"
  185. #define USING_DLL_UI
  186. /* define flags for DLL_UI */
  187. #define IN_PC_SIMULATOR (1)
  188. #ifdef __CUSTOMER_LEVEL_1_RELEASE__
  189. #define IN_LEVEL_1_RELEASE (2)
  190. #else
  191. #define IN_LEVEL_1_RELEASE (0)
  192. #endif
  193. /***************************************************************************** 
  194. * Typedef 
  195. *****************************************************************************/
  196. /***************************************************************************** 
  197. * Local Variable
  198. *****************************************************************************/
  199. HWND hWnd;
  200. HWND hDlg;
  201. BOOL bFlagNWSimulatorStart = FALSE;
  202. static BOOL is_first_bootup = TRUE;
  203. static char skin_name_buffer[BUFFER_LENGTH];
  204. static char old_skin_name_buffer[BUFFER_LENGTH];
  205. #ifndef __CUSTOMER_LEVEL_1_RELEASE__
  206. CNWSimEngine NWSimEngine;
  207. #endif
  208. static char PrintableStr[256];
  209. FILE *DebugFile; 
  210. char cwd[BUFFER_LENGTH];
  211. char old_cwd[BUFFER_LENGTH];
  212. /***************************************************************************** 
  213. * Local Function
  214. *****************************************************************************/
  215. BOOL  CALLBACK LoadSkinsProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
  216. static void LoadSkins(HINSTANCE hInstance, HWND hwnd);
  217. static void ListSkinsInDir(HWND hDlg, char path[], HWND hLB);
  218. void keydown_by_mouse(HWND hWnd, int xPos, int yPos);
  219. void keyup_by_mouse(HWND hWnd);
  220. void keyup_by_shortcut(HWND hWnd, unsigned int wParam);
  221. void keydown_by_shortcut(HWND hWnd, int wParam);
  222. void mouse_move_enable(HWND hWnd, int xPos, int yPos);
  223. void key_detect_ind(unsigned char key_status, unsigned char key_code);
  224. void charger_inout(void);
  225. void incoming_call(void);
  226. void draw_main_bitmap(HDC hdc);
  227. void launch_nw_simulator(void);
  228. void shutdown_system_operation(void);
  229. void on_timer(unsigned int id);
  230. void automatic_power_on(void);
  231. BOOL writeKeyMsgOnCondition(MYQUEUE *Message);
  232. /***************************************************************************** 
  233. * Global Variable
  234. *****************************************************************************/
  235. extern "C" s32 simulator_skin_sub_LCD_x;
  236. extern "C" s32 SUB_LCD_device_width;
  237. extern "C" BOOL IsLcdFirstInit;
  238. #ifdef USING_DLL_UI
  239. extern "C" BOOL using_dll_ui = TRUE;
  240. #else
  241. extern "C" BOOL using_dll_ui = FALSE;
  242. #endif
  243. /***************************************************************************** 
  244. * Global Function
  245. *****************************************************************************/
  246. /* quit whole system opeartion */
  247. extern "C" void ShutdownSystemOperation(void);
  248. extern "C" void FeedBackFeelingKeyAction(int key);
  249. extern "C" void FeedBackFeelingKeyInit(HWND hWnd, HINSTANCE hInstance, HBITMAP main_hbitmap);
  250. extern "C" void InitPCSimulatorBootup(void);
  251. extern "C" void ResetKeyMemory();
  252. extern "C" void ReadKeyProfile(char in_path[], HWND hWnd);
  253. extern "C" BOOL GetSimulatorBootStatus();
  254. extern "C" HWND GetDialogHandle();
  255. extern "C" HWND GetWindowHandle();
  256. extern "C" void lcd_screen_init(HWND hWnd, HINSTANCE hInstance);
  257. extern "C" void update_screen();
  258. extern "C" void lcd_dspl_init();
  259. extern "C" __declspec(dllimport)
  260. void MtkWinDllStart(
  261. void (*w32_key_detect_ind_callback)(unsigned char, unsigned char),
  262. void (*w32_charger_inout_callback)(void),
  263. void (*w32_incoming_call_callback)(void),
  264. void (*w32_screen_init_callback)(HWND, HINSTANCE),
  265. void (*w32_keydown_by_mouse_callback)(HWND, int, int),
  266. void (*w32_keyup_by_mouse_callback)(HWND),
  267. void (*w32_keydown_by_shortcut_callback)(HWND, int),
  268. void (*w32_keyup_by_shortcut_callback)(HWND, unsigned int),
  269. void (*w32_mouse_move_enable_callback)(HWND, int, int),
  270. void (*w32_draw_main_bitmap_callback)(HDC),
  271. void (*w32_update_screen_callback)(void),
  272. void (*w32_TASK_Initialization_callback)(void),
  273. void (*w32_ReadKeyProfile_callback)(char [], HWND hwnd),
  274. void (*w32_ResetKeyMemory_callback)(void),
  275. void (*w32_dspl_init_callback)(void),
  276. void (*pc_sim_shutdown_callback)(void),
  277. void (*pc_sim_launch_nw_sim_callback)(void),
  278. void (*pc_sim_on_timer_callback)(unsigned int),
  279. int  pc_simulator_flag
  280. );
  281. /*****************************************************************************
  282.  * FUNCTION
  283.  *  DebugInfo
  284.  * DESCRIPTION
  285.  *  logging debug information (only for PC simulator thread)
  286.  * PARAMETERS
  287.  *  arg_type   [IN]     arguement type
  288.  *  ...        [IN]     variable number paramemter list
  289.  * RETURNS
  290.  *  void
  291.  *****************************************************************************/
  292. static void DebugInfo(S8 *arg_type, ...)
  293. {
  294.     /*----------------------------------------------------------------*/
  295.     /* Local Variables                                                */
  296.     /*----------------------------------------------------------------*/
  297.     va_list MyList;
  298.     /*----------------------------------------------------------------*/
  299.     /* Code Body                                                      */
  300.     /*----------------------------------------------------------------*/
  301.     va_start(MyList, arg_type);
  302.     vsprintf(PrintableStr, arg_type, MyList);
  303.     va_end(MyList);
  304.     if (DebugFile)
  305.     {
  306.         fputs(PrintableStr, DebugFile);
  307.     }
  308.     flushall();
  309.     return;
  310. }
  311. /*****************************************************************************
  312. * FUNCTION
  313. *  WinMain_ext
  314. * DESCRIPTION
  315. *   Entry point of application.
  316. *
  317. * PARAMETERS
  318. *  hInstance IN HINSTANCE
  319. *  hPrevInstance IN HINSTANCE
  320. * lpCmdLine IN LPSTR
  321. * nCmdShow IN nCmdShow
  322. * RETURNS
  323. *   int APIENTRY
  324. * GLOBALS AFFECTED
  325. *   nil
  326. *****************************************************************************/
  327. int APIENTRY WinMain_ext(HINSTANCE hInstance,
  328.                      HINSTANCE hPrevInstance,
  329.                      LPSTR     lpCmdLine,
  330.                      int       nCmdShow)
  331. {
  332.    /*----------------------------------------------------------------*/
  333.    /* Local Variables                                                */
  334.    /*----------------------------------------------------------------*/
  335. #ifndef USING_DLL_UI
  336. MSG msg;
  337. HACCEL hAccelTable;
  338. #endif
  339. /*----------------------------------------------------------------*/
  340.    /* Code Body                                                      */
  341.    /*----------------------------------------------------------------*/
  342. #ifndef USING_DLL_UI
  343. /* Initialize global strings */
  344. LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  345. LoadString(hInstance, IDC_MTK_SIMULATOR, szWindowClass, MAX_LOADSTRING);
  346. MyRegisterClass(hInstance);
  347. /* Perform application initialization: */
  348. if (!InitInstance (hInstance, nCmdShow)) 
  349. {
  350. return FALSE;
  351. }
  352. hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MTK_SIMULATOR);
  353. /************* Vijay *****************/
  354. /* Call the function to initialze the MMI */
  355. InitApplication();
  356. #endif
  357.     /* open debugging information file */
  358.     {
  359.         if (!(DebugFile = fopen("debug.log", "w")))
  360.         {
  361.             exit(1);
  362.         }
  363.     }
  364. #ifdef USING_DLL_UI
  365. SetCurrentDirectory(".\Debug");
  366. /************* Vincent ***************/
  367. /* SHOW DLL UI */
  368. MtkWinDllStart(
  369. key_detect_ind,
  370. charger_inout,
  371. incoming_call,
  372. lcd_screen_init,
  373. keydown_by_mouse,
  374. keyup_by_mouse,
  375. keydown_by_shortcut,
  376. keyup_by_shortcut,
  377. mouse_move_enable,
  378. draw_main_bitmap,
  379. update_screen,
  380. InitApplication,
  381. ReadKeyProfile,
  382. ResetKeyMemory,
  383. lcd_dspl_init,
  384. shutdown_system_operation,
  385. launch_nw_simulator,
  386. on_timer,
  387. IN_PC_SIMULATOR | IN_LEVEL_1_RELEASE
  388. );
  389. /* wait the dll UI up */
  390. Sleep(1000);
  391. SetCurrentDirectory("..\");
  392. #endif
  393. #ifndef USING_DLL_UI
  394. /************* Vijay *****************/
  395. /* Main message loop: */
  396. while (GetMessage(&msg, NULL, 0, 0)) 
  397. {
  398. /* if(!gbIsCustomizerOn) */
  399. /* { */
  400. if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
  401. {
  402. TranslateMessage(&msg);
  403. DispatchMessage(&msg);
  404. }
  405. /* } */
  406. }
  407.     {
  408.         fclose(DebugFile);
  409.     }
  410. return msg.wParam;
  411. #endif
  412. #ifdef USING_DLL_UI
  413. return 0;
  414. #endif
  415. } /* end of WinMain */
  416. /*****************************************************************************
  417. * FUNCTION
  418. *  AutomaticBoopup
  419. * DESCRIPTION
  420. *   MTK added by JL 040319 for level 1 auto bootup release
  421. *
  422. * PARAMETERS
  423. *  hwnd IN HWND
  424. *  uMsg IN UINT
  425. * idEvent IN UINT
  426. * dwTime IN DWORD
  427. * RETURNS
  428. * nil
  429. * GLOBALS AFFECTED
  430. * nil
  431. *****************************************************************************/
  432. #if defined(__CUSTOMER_LEVEL_1_RELEASE__)
  433. void CALLBACK AutomaticBoopup(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
  434. {
  435. /*----------------------------------------------------------------*/
  436.    /* Local Variables                                                */
  437.    /*----------------------------------------------------------------*/
  438.    static bool is_first_time_bootup = FALSE;
  439. /*----------------------------------------------------------------*/
  440.    /* Code Body                                                      */
  441.    /*----------------------------------------------------------------*/
  442. bFlagNWSimulatorStart = TRUE;
  443. if (!is_first_time_bootup)
  444. {
  445. InitPCSimulatorBootup();
  446. is_first_time_bootup = TRUE;
  447. }
  448. } /* end of AutomaticBoopup */
  449. #endif
  450. /*****************************************************************************
  451. * FUNCTION
  452. *  MyRegisterClass
  453. * DESCRIPTION
  454. * Registers the window class.
  455. * This function and its usage is only necessary if you want this code
  456. * to be compatible with Win32 systems prior to the 'RegisterClassEx'
  457. * function that was added to Windows 95. It is important to call this function
  458. * so that the application will get 'well formed' small icons associated
  459. * with it.
  460. *
  461. * PARAMETERS
  462. *  hInstance IN HINSTANCE
  463. * RETURNS
  464. * ATOM
  465. * GLOBALS AFFECTED
  466. * nil
  467. *****************************************************************************/
  468. ATOM MyRegisterClass(HINSTANCE hInstance)
  469. {
  470. /*----------------------------------------------------------------*/
  471.    /* Local Variables                                                */
  472.    /*----------------------------------------------------------------*/
  473. WNDCLASSEX wcex;
  474. /*----------------------------------------------------------------*/
  475.    /* Code Body                                                      */
  476.    /*----------------------------------------------------------------*/
  477. wcex.cbSize = sizeof(WNDCLASSEX); 
  478. wcex.style = CS_HREDRAW | CS_VREDRAW;
  479. wcex.lpfnWndProc = (WNDPROC)WndProc;
  480. wcex.cbClsExtra = 0;
  481. wcex.cbWndExtra = 0;
  482. wcex.hInstance = hInstance;
  483. wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_L_MTK);
  484. wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  485. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
  486. wcex.lpszMenuName = /*(LPCSTR)*/MAKEINTRESOURCE(IDC_MTK_SIMULATOR);
  487. wcex.lpszClassName = szWindowClass;
  488. wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_S_MTK/*IDI_SMALL*/);
  489. return RegisterClassEx(&wcex);
  490. } /* end of MyRegisterClass */
  491. /*****************************************************************************
  492. * FUNCTION
  493. *  InitInstance
  494. * DESCRIPTION
  495. * Saves instance handle and creates main window. Load the default skin.
  496. * In this function, we save the instance handle in a global variable and
  497. * create and display the main program window.
  498. *
  499. * PARAMETERS
  500. *  hInstance IN HINSTANCE
  501. *  nCmdShow IN int
  502. * RETURNS
  503. * BOOL
  504. * GLOBALS AFFECTED
  505. * nil
  506. *****************************************************************************/
  507. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  508. {
  509.    /*----------------------------------------------------------------*/
  510.    /* Local Variables                                                */
  511.    /*----------------------------------------------------------------*/
  512. RECT rcClient;
  513. char buffer1[BUFFER_LENGTH], buffer2[BUFFER_LENGTH];
  514. /*----------------------------------------------------------------*/
  515.    /* Code Body                                                      */
  516.    /*----------------------------------------------------------------*/
  517. /* Store instance handle in our global variable */
  518. hInst = hInstance;
  519. #ifndef __MMI_SUBLCD__
  520. hWnd = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU,
  521. CW_USEDEFAULT, 0, 238/*simulator_skin_sub_LCD_x*/, 540, NULL, NULL, hInstance, NULL);
  522. #else
  523. hWnd = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU,
  524. CW_USEDEFAULT, 0, 238/*simulator_skin_sub_LCD_x*/+SUB_LCD_device_width+14, 540, NULL, NULL, hInstance, NULL);
  525. #endif
  526.    /* WindowHandle(hWnd); */
  527. /* gets rect pos for console window */ 
  528. GetClientRect(hWnd, &rcClient); 
  529. /* sets console window pos */ 
  530. SetWindowPos(hWnd, HWND_TOP, rcClient.left + 20, rcClient.top + 40, 0, 0, SWP_NOSIZE); 
  531.    
  532. /* Remove the unwanted menu items. */
  533. if (hWnd != NULL)
  534. {
  535. HMENU menu = ::GetSystemMenu(hWnd, FALSE);
  536. if (menu != NULL)
  537. {
  538. ::RemoveMenu(menu, SC_SIZE, MF_BYCOMMAND); /* Size isn't supported for the same reason. */
  539. }
  540. }
  541. if (!hWnd)
  542. {
  543. return FALSE;
  544. }
  545. GetCurrentDirectory(BUFFER_LENGTH, cwd);
  546. /* check if the previous loaded skin exists, or load the default skin */
  547. GetPrivateProfileString("Log", "LAST_SKIN_NAME", NULL, buffer1, BUFFER_LENGTH, "../Skins/SkinStyleLog.ini");
  548. /* get currect working directory */
  549. GetCurrentDirectory(BUFFER_LENGTH, buffer2);
  550. /* no key value or the directory does not exist */
  551. if (strcmp(buffer1, "") == 0 || SetCurrentDirectory(buffer1) == 0)
  552. {
  553. /* restore to the current working directory */
  554. SetCurrentDirectory(buffer2);
  555. /* load the default skin */
  556. GetPrivateProfileString("Default", "DEFAULT_SKIN_PATH", NULL, buffer1, BUFFER_LENGTH, "../Skins/SkinStyleLog.ini");
  557. GetPrivateProfileString("Default", "DEFAULT_SKIN_STYLE", NULL, buffer2, BUFFER_LENGTH, "../Skins/SkinStyleLog.ini");
  558. sprintf(skin_name_buffer, "%s%s", buffer1, buffer2);
  559. /* write current skin style to the last used skin name */
  560. WritePrivateProfileString("Log", "LAST_SKIN_NAME", skin_name_buffer, "../Skins/SkinStyleLog.ini");
  561. }
  562. else
  563. {
  564. /* restore to the current working directory */
  565. SetCurrentDirectory(buffer2);
  566. /* Get the last used skin name */
  567. strcpy(skin_name_buffer, buffer1);
  568. }
  569. ResetKeyMemory();
  570. strcpy(old_skin_name_buffer, skin_name_buffer);
  571. ReadKeyProfile(skin_name_buffer, hWnd);
  572. lcd_screen_init(hWnd, 0);
  573. FeedBackFeelingKeyInit(hWnd, NULL, NULL/*(HBITMAP)hBitmap*/);
  574.    ShowWindow(hWnd, nCmdShow);
  575. UpdateWindow(hWnd);
  576. return TRUE;
  577. } /* end of InitInstance */
  578. /*****************************************************************************
  579. * FUNCTION
  580. *  WndProc
  581. * DESCRIPTION
  582. * Processes messages for the main window.
  583. * WM_COMMAND - process the application menu
  584. * WM_PAINT - Paint the main window
  585. * WM_DESTROY - post a quit message and return
  586. *
  587. * PARAMETERS
  588. *  hWnd IN HWND
  589. *  message IN UINT
  590. * wParam IN WPARAM
  591. * lParam IN LPARAM
  592. * RETURNS
  593. * LRESULT CALLBACK
  594. * GLOBALS AFFECTED
  595. * nil
  596. *****************************************************************************/
  597. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  598. {
  599. /*----------------------------------------------------------------*/
  600.    /* Local Variables                                                */
  601.    /*----------------------------------------------------------------*/
  602. int wmId, wmEvent;
  603. PAINTSTRUCT ps;
  604. HDC hdc;
  605. static MYQUEUE Message;
  606. HINSTANCE hInstance;
  607. static bool flg;
  608. /*----------------------------------------------------------------*/
  609.    /* Code Body                                                      */
  610.    /*----------------------------------------------------------------*/
  611. switch (message) 
  612. {
  613. case WM_COMMAND:
  614. wmId    = LOWORD(wParam); 
  615. wmEvent = HIWORD(wParam); 
  616. /* Parse the menu selections: */
  617. switch (wmId)
  618. {
  619. case IDM_ABOUT:
  620.    DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
  621. break;
  622. case IDM_EXIT:
  623. {
  624. flg = true;
  625. if (flg == true)
  626. {
  627. flg = false;
  628. ShutdownSystemOperation();
  629. #ifndef __CUSTOMER_LEVEL_1_RELEASE__
  630. NWSimEngine.SendShutDownMsg();
  631. #endif
  632. }
  633.     /* DestroyWindow(hWnd); */
  634. }
  635.    break;
  636. /* MTK added by JL 040319 for level 1 auto bootup release */
  637. //#if !defined(__CUSTOMER_LEVEL_1_RELEASE__)
  638. /* Vincent: move this compile option to the body of launch_nw_simulator()
  639.  * for compatible with DLL_UI
  640.  */
  641. case ID_FILE_NETWORKS:
  642. launch_nw_simulator();
  643. break;
  644. //#endif
  645. /* when the ser pressed the load skin menu item */
  646. case ID_LOAD_SKINS:
  647. GetCurrentDirectory(BUFFER_LENGTH, old_cwd);
  648. SetCurrentDirectory(cwd);
  649. hInstance = GetModuleHandle(NULL);
  650. LoadSkins(hInstance, hWnd);
  651. //SetCurrentDirectory(old_cwd);
  652. break;
  653. default:
  654.    return DefWindowProc(hWnd, message, wParam, lParam);
  655. }
  656. break; 
  657. /* MTK added by JL 040319 for level 1 auto bootup release */
  658. //#if defined(__CUSTOMER_LEVEL_1_RELEASE__)
  659. /* Vincent: move this compile option to the body of automatic_power_on()
  660.  * for compatible with DLL_UI
  661.  */
  662. case WM_SHOWWINDOW:
  663. automatic_power_on();
  664. break;
  665. //#endif
  666. case WM_PAINT:
  667. hdc = BeginPaint(hWnd, &ps);
  668. SkinDisplay(hWnd);
  669. RefereshWindow(hWnd);
  670. EndPaint(hWnd, &ps);
  671. break;
  672. case WM_LBUTTONDOWN:
  673. keydown_by_mouse(hWnd, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
  674. break;
  675. case WM_LBUTTONUP:
  676. keyup_by_mouse(hWnd);
  677. break;
  678. case WM_MOUSEMOVE:
  679. mouse_move_enable(hWnd, GET_X_LPARAM(lParam), GET_X_LPARAM(lParam));
  680. break;
  681. case WM_KEYUP:
  682. keyup_by_shortcut(hWnd, wParam);
  683. break;
  684. case WM_KEYDOWN:
  685. keydown_by_shortcut(hWnd, (int)wParam);
  686. break;
  687. case WM_CLOSE:
  688. {
  689. flg = true;
  690. if (flg == true)
  691. {
  692. flg = false;
  693. ShutdownSystemOperation();
  694. #ifndef __CUSTOMER_LEVEL_1_RELEASE__
  695. NWSimEngine.SendShutDownMsg();
  696. #endif
  697. }
  698. }
  699. break;
  700. case MM_MCINOTIFY:
  701. break;
  702. case WM_TIMER:
  703. on_timer((unsigned int)wParam);
  704. break;
  705. case WM_DESTROY:
  706. PostQuitMessage(0);
  707. default:
  708. return DefWindowProc(hWnd, message, wParam, lParam);
  709. }
  710.    return 0;
  711. } /* end of WndProc */
  712. /*****************************************************************************
  713. * FUNCTION
  714. *  About
  715. * DESCRIPTION
  716. *   Mesage handler for about box.
  717. *
  718. * PARAMETERS
  719. *  hWnd IN HWND
  720. *  message IN UINT
  721. * wParam IN WPARAM
  722. * lParam IN LPARAM
  723. * RETURNS
  724. * LRESULT CALLBACK
  725. * GLOBALS AFFECTED
  726. * nil
  727. *****************************************************************************/
  728. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  729. {
  730. /*----------------------------------------------------------------*/
  731.    /* Local Variables                                                */
  732.    /*----------------------------------------------------------------*/
  733. /*----------------------------------------------------------------*/
  734.    /* Code Body                                                      */
  735.    /*----------------------------------------------------------------*/
  736. switch (message)
  737. {
  738. case WM_INITDIALOG:
  739. return TRUE;
  740. case WM_COMMAND:
  741. if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
  742. {
  743. EndDialog(hDlg, LOWORD(wParam));
  744. return TRUE;
  745. }
  746. break;
  747. }
  748.     return FALSE;
  749. } /* end of About */
  750. /*****************************************************************************
  751. * FUNCTION
  752. * LoadSkins
  753. * DESCRIPTION
  754. * Setup the dialog for loading skin
  755. *
  756. * PARAMETERS
  757. *  hInstance IN HINSTANCE
  758. * hwnd IN HWND
  759. * RETURNS
  760. * nil
  761. * GLOBALS AFFECTED
  762. * nil
  763. *****************************************************************************/
  764. static void LoadSkins(HINSTANCE hInstance, HWND hwnd)
  765. {
  766. /*----------------------------------------------------------------*/
  767.    /* Local Variables                                                */
  768.    /*----------------------------------------------------------------*/
  769. HWND hLB, hCB;
  770. char buffer[BUFFER_LENGTH];
  771. RECT dlg_rect, wnd_rect;
  772. /*----------------------------------------------------------------*/
  773.    /* Code Body                                                      */
  774.    /*----------------------------------------------------------------*/
  775. hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_LOADSKIN), hwnd, (DLGPROC)LoadSkinsProc);
  776. hCB = GetDlgItem(hDlg, IDC_SKIN_SIZE);
  777. SendMessage(hCB, CB_RESETCONTENT, 0, 0); 
  778. /* add items to the combo box */
  779. strcpy(buffer, "128 x 128");
  780. SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)buffer);
  781. strcpy(buffer, "128 x 160");
  782. SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)buffer);
  783. strcpy(buffer, "176 x 220");
  784. SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)buffer);
  785. strcpy(buffer, "240 x 320");
  786. SendMessage(hCB, CB_ADDSTRING, 0, (LPARAM)buffer);
  787. hLB = GetDlgItem(hDlg, IDC_SKIN_NAMES);
  788. /* move to the directory containing the skin directories */
  789. /* the default skin size is 176x220 */
  790. SendMessage(hCB, CB_SETCURSEL, 2, 0);
  791. strcpy(buffer, PATH_FOR_176x220);
  792. /* show all skins in this dimension */
  793. ListSkinsInDir(hDlg, buffer, hLB);
  794. /* shift the dialog to be align with the main windows */
  795. GetWindowRect(hwnd, &wnd_rect);
  796. GetWindowRect(hDlg, &dlg_rect);
  797. MoveWindow(hDlg, wnd_rect.right, wnd_rect.top, dlg_rect.right - dlg_rect.left + 1, dlg_rect.bottom - dlg_rect.top + 1, TRUE);
  798. ShowWindow(hDlg, SW_SHOW);
  799. } /* end of LoadSkins */
  800. /*****************************************************************************
  801. * FUNCTION
  802. * LoadSkinsProc
  803. * DESCRIPTION
  804. * Procedure for loading-skin dialog
  805. *
  806. * PARAMETERS
  807. *  hwndDlg IN handle for dialog
  808. * message IN message
  809. * wParam IN WPARAM
  810. * lParam IN LPARAM
  811. * RETURNS
  812. * BOOL CALLBACK
  813. * GLOBALS AFFECTED
  814. * nil
  815. *****************************************************************************/
  816. BOOL CALLBACK LoadSkinsProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
  817. {
  818. /*----------------------------------------------------------------*/
  819.    /* Local Variables                                                */
  820.    /*----------------------------------------------------------------*/
  821. char buffer[BUFFER_LENGTH];
  822. int selected_index;
  823. /*----------------------------------------------------------------*/
  824.    /* Code Body                                                      */
  825.    /*----------------------------------------------------------------*/
  826. switch (message) 
  827. case WM_COMMAND: 
  828. switch (LOWORD(wParam)) 
  829. case IDOK:
  830. /* backup current skin setting */
  831. strcpy(old_skin_name_buffer, skin_name_buffer);
  832. EndDialog(hwndDlg, wParam);
  833. /* write the current skin setting to the INI file */
  834. WritePrivateProfileString("Log", "LAST_SKIN_NAME", skin_name_buffer, "../Skins/SkinStyleLog.ini");
  835. return TRUE;
  836.   case IDCANCEL:
  837. /* restore the skin setting to the original one */
  838. strcpy(skin_name_buffer, old_skin_name_buffer);
  839. /* display the skin */
  840. ReadKeyProfile(skin_name_buffer, hWnd);
  841. IsLcdFirstInit = TRUE;
  842. SkinDisplay(hWnd);
  843. SendMessage(hWnd, WM_PAINT, 0, 0);
  844. EndDialog(hwndDlg, wParam);
  845. return TRUE;
  846. /* message from the list box */
  847. case IDC_SKIN_NAMES:
  848. if (HIWORD(wParam) == LBN_SELCHANGE)
  849. {
  850. selected_index = SendMessage(GetDlgItem(hwndDlg, IDC_SKIN_NAMES), LB_GETCURSEL, 0, 0);
  851. /* if there is a skin selected */
  852. if (selected_index >= 0)
  853. {
  854. SendMessage(GetDlgItem(hwndDlg, IDC_SKIN_NAMES), LB_GETTEXT, selected_index, (LPARAM)buffer);
  855. /* get the type of skin */
  856. switch (SendMessage(GetDlgItem(hwndDlg, IDC_SKIN_SIZE), CB_GETCURSEL, 0, 0))
  857. {
  858. case SKIN_128x128:
  859. strcpy(skin_name_buffer, PATH_FOR_128x128);
  860. break;
  861. case SKIN_128x160:
  862. strcpy(skin_name_buffer, PATH_FOR_128x160);
  863. break;
  864. case SKIN_176x220:
  865. strcpy(skin_name_buffer, PATH_FOR_176x220);
  866. break;
  867. case SKIN_240x320:
  868. strcpy(skin_name_buffer, PATH_FOR_240x320);
  869. break;
  870. }
  871. /* remove the brace "[]" from the string */
  872. buffer[strlen(buffer) - 1] = '';
  873. strcpy(buffer, &buffer[1]);
  874. sprintf(skin_name_buffer, "%s%c%s", skin_name_buffer, '/', buffer);
  875. /* display the skin */
  876. ReadKeyProfile(skin_name_buffer, hWnd);
  877. IsLcdFirstInit = TRUE;
  878. SkinDisplay(hWnd);
  879. SendMessage(hWnd, WM_PAINT, 0, 0);
  880. }
  881. }
  882. break;
  883. /* message from the combo box */
  884. case IDC_SKIN_SIZE:
  885. switch (HIWORD(wParam))
  886. {
  887. case CBN_SELCHANGE:
  888. /* detect which skin dimension is selected */
  889. switch (SendMessage(GetDlgItem(hwndDlg, IDC_SKIN_SIZE), CB_GETCURSEL, 0, 0))
  890. {
  891. case SKIN_128x128:
  892. strcpy(buffer, PATH_FOR_128x128);
  893. ListSkinsInDir(hwndDlg, buffer, GetDlgItem(hwndDlg, IDC_SKIN_NAMES));
  894. break;
  895. case SKIN_128x160:
  896. strcpy(buffer, PATH_FOR_128x160);
  897. ListSkinsInDir(hwndDlg, buffer, GetDlgItem(hwndDlg, IDC_SKIN_NAMES));
  898. break;
  899. case SKIN_176x220:
  900. strcpy(buffer, PATH_FOR_176x220);
  901. ListSkinsInDir(hwndDlg, buffer, GetDlgItem(hwndDlg, IDC_SKIN_NAMES));
  902. break;
  903. case SKIN_240x320:
  904. strcpy(buffer, PATH_FOR_240x320);
  905. ListSkinsInDir(hwndDlg, buffer, GetDlgItem(hwndDlg, IDC_SKIN_NAMES));
  906. break;
  907. }
  908. break;
  909. }
  910. break;
  911. }
  912. return FALSE;
  913. } /* end of LoadSkinsProc */
  914. /*****************************************************************************
  915. * FUNCTION
  916. * ListSkinsInDir
  917. * DESCRIPTION
  918. * Setup the dialog for loading skin
  919. *
  920. * PARAMETERS
  921. *  hDlg IN handle for dialog
  922. * path IN where the skin is
  923. * hLB IN handle for list box
  924. * RETURNS
  925. * nil
  926. * GLOBALS AFFECTED
  927. * nil
  928. *****************************************************************************/
  929. static void ListSkinsInDir(HWND hDlg, char path[], HWND hLB)
  930. {
  931. /*----------------------------------------------------------------*/
  932.    /* Local Variables                                                */
  933.    /*----------------------------------------------------------------*/
  934. char buffer[BUFFER_LENGTH];
  935. LRESULT result = 0;
  936. /*----------------------------------------------------------------*/
  937.    /* Code Body                                                      */
  938.    /*----------------------------------------------------------------*/
  939. /* get current working directory */
  940. GetCurrentDirectory(BUFFER_LENGTH, buffer);
  941. /* fill the list box with all skins in this directory */
  942. DlgDirList(hDlg, path, IDC_SKIN_NAMES, 0, DDL_DIRECTORY | DDL_EXCLUSIVE);
  943. /* deletet the ".." directory showed in the list box */
  944. SendMessage(hLB, LB_DELETESTRING, 0, 0);
  945. /* select the first item in the list box */
  946. result = SendMessage(hLB, LB_GETCOUNT, 0, 0);
  947. /* if there is no skin in that directory, make the OK button unavailable */
  948. if (result == 0)
  949. {
  950. EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);
  951. }
  952. else
  953. {
  954. EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);
  955. }
  956. /* restore the working directory back */
  957. SetCurrentDirectory(buffer);
  958. } /* end of ListSkinsInDir */
  959. /*****************************************************************************
  960. * FUNCTION
  961. * GetSimulatorBootStatus
  962. * DESCRIPTION
  963. * Get simulator boot status
  964. *
  965. * PARAMETERS
  966. *  nil
  967. * RETURNS
  968. * BOOL
  969. * GLOBALS AFFECTED
  970. * nil
  971. *****************************************************************************/
  972. BOOL GetSimulatorBootStatus()
  973. {
  974. /*----------------------------------------------------------------*/
  975.    /* Local Variables                                                */
  976.    /*----------------------------------------------------------------*/
  977. /*----------------------------------------------------------------*/
  978.    /* Code Body                                                      */
  979.    /*----------------------------------------------------------------*/
  980. return bFlagNWSimulatorStart;
  981. } /* end of GetSimulatorBootStatus */
  982. /*****************************************************************************
  983. * FUNCTION
  984. * GetDialogHandle
  985. * DESCRIPTION
  986. * Get the handle of the skin-loading dialog
  987. *
  988. * PARAMETERS
  989. *  nil
  990. * RETURNS
  991. * HWND
  992. * GLOBALS AFFECTED
  993. * nil
  994. *****************************************************************************/
  995. HWND GetDialogHandle()
  996. {
  997. /*----------------------------------------------------------------*/
  998.    /* Local Variables                                                */
  999.    /*----------------------------------------------------------------*/
  1000. /*----------------------------------------------------------------*/
  1001.    /* Code Body                                                      */
  1002.    /*----------------------------------------------------------------*/
  1003. return hDlg;
  1004. } /* end of GetDialogHandle */
  1005. /*****************************************************************************
  1006. * FUNCTION
  1007. * GetWindowHandle
  1008. * DESCRIPTION
  1009. * Get the handle of the main window
  1010. *
  1011. * PARAMETERS
  1012. *  nil
  1013. * RETURNS
  1014. * HWND
  1015. * GLOBALS AFFECTED
  1016. * nil
  1017. *****************************************************************************/
  1018. HWND GetWindowHandle()
  1019. {
  1020. /*----------------------------------------------------------------*/
  1021.    /* Local Variables                                                */
  1022.    /*----------------------------------------------------------------*/
  1023. /*----------------------------------------------------------------*/
  1024.    /* Code Body                                                      */
  1025.    /*----------------------------------------------------------------*/
  1026. return hWnd;
  1027. } /* end of GetDialogHandle */
  1028. /*****************************************************************************
  1029. * FUNCTION
  1030. *  keydown_by_mouse
  1031. * DESCRIPTION
  1032. *  function for mouse button down
  1033. *
  1034. * PARAMETERS
  1035. * hWnd IN window handle
  1036. * xPos IN X position
  1037. * yPos IN Y position
  1038. * RETURNS
  1039. *  void
  1040. * GLOBALS AFFECTED
  1041. *  void
  1042. *****************************************************************************/
  1043. void keydown_by_mouse(HWND hWnd, int xPos, int yPos)
  1044. {
  1045. /*----------------------------------------------------------------*/
  1046.    /* Local Variables                                                */
  1047.    /*----------------------------------------------------------------*/
  1048. UINT i;
  1049. void *tempKeyBrdMsg;
  1050. static MYQUEUE Message;
  1051. KEYBRD_MESSAGE *KeyBrdMsg;
  1052. /*----------------------------------------------------------------*/
  1053.    /* Code Body                                                      */
  1054.    /*----------------------------------------------------------------*/
  1055. #if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
  1056. if(!TouchScreenSimButtonDown() && (i = GetKeyCode()) != KEY_INVALID)
  1057. #else
  1058. if((i = GetKeyCode()) != KEY_INVALID)
  1059. #endif
  1060. {
  1061.         MessageBeep(0xFFFFFFFF);
  1062.         Message.oslSrcId = 0xFFFF;
  1063.         Message.oslDestId = MOD_PRT;
  1064.         Message.oslMsgId = WM_LBUTTONDOWN;
  1065.         /* OslFreeDataPtr(Message.oslDataPtr); */
  1066.         tempKeyBrdMsg=OslConstructDataPtr(sizeof(KEYBRD_MESSAGE));
  1067.         KeyBrdMsg =(KEYBRD_MESSAGE *)tempKeyBrdMsg;
  1068.         /* KeyBrdMsg = (KEYBRD_MESSAGE *)OslConstructDataPtr(sizeof(KEYBRD_MESSAGE)); */
  1069.         KeyBrdMsg->nKeyCode = i;
  1070.         Message.oslDataPtr = KeyBrdMsg;
  1071.         if (writeKeyMsgOnCondition(&Message) != TRUE)
  1072.             OslFreeDataPtr(tempKeyBrdMsg);
  1073. /* JL/PLUTO: To draw the feedback feeling button */
  1074. FeedBackFeelingKeyAction(i);
  1075. }
  1076. } /* end of keydown_by_mouse */
  1077. /*****************************************************************************
  1078. * FUNCTION
  1079. *  keyup_by_mouse
  1080. * DESCRIPTION
  1081. *  function for mouse button up
  1082. *
  1083. * PARAMETERS
  1084. * hWnd IN window handle
  1085. * RETURNS
  1086. *  void
  1087. * GLOBALS AFFECTED
  1088. *  void
  1089. *****************************************************************************/
  1090. void keyup_by_mouse(HWND hWnd)
  1091. {
  1092. /*----------------------------------------------------------------*/
  1093.    /* Local Variables                                                */
  1094.    /*----------------------------------------------------------------*/
  1095. UINT i;
  1096. void *tempKeyBrdMsg;
  1097. static MYQUEUE Message;
  1098. KEYBRD_MESSAGE *KeyBrdMsg;
  1099. /*----------------------------------------------------------------*/
  1100.    /* Code Body                                                      */
  1101.    /*----------------------------------------------------------------*/
  1102. /* MessageBeep(0xFFFFFFFF); */
  1103. #if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
  1104. if(!TouchScreenSimButtonUp() && (i = GetKeyCode()) != KEY_INVALID)
  1105. #else
  1106. if((i = GetKeyCode()) != KEY_INVALID)
  1107. #endif
  1108. {
  1109.     /* JL/PLUTO: To recover the original skin */
  1110. draw_main_bitmap(NULL);
  1111.         Message.oslSrcId = 0xFFFF;
  1112.         Message.oslDestId=MOD_PRT;
  1113.         Message.oslMsgId =WM_LBUTTONUP;
  1114.         /* OslFreeDataPtr(Message.oslDataPtr); */
  1115.         tempKeyBrdMsg = OslConstructDataPtr(sizeof(KEYBRD_MESSAGE));
  1116.         KeyBrdMsg = (KEYBRD_MESSAGE *)tempKeyBrdMsg;
  1117.         /* KeyBrdMsg = (KEYBRD_MESSAGE *)OslConstructDataPtr(sizeof(KEYBRD_MESSAGE)); */
  1118.         KeyBrdMsg->nKeyCode = i;
  1119.         Message.oslDataPtr=KeyBrdMsg;
  1120.         if (writeKeyMsgOnCondition(&Message) != TRUE)
  1121.             OslFreeDataPtr(tempKeyBrdMsg);
  1122. }
  1123. } /* end of keyup_by_mouse */
  1124. /*****************************************************************************
  1125. * FUNCTION
  1126. *  keyup_by_shortcut
  1127. * DESCRIPTION
  1128. *  function for key down
  1129. *
  1130. * PARAMETERS
  1131. * hWnd IN window handle
  1132. * wParam IN wParam
  1133. * RETURNS
  1134. *  void
  1135. * GLOBALS AFFECTED
  1136. *  void
  1137. *****************************************************************************/
  1138. void keyup_by_shortcut(HWND hWnd, unsigned int wParam)
  1139. {
  1140. /*----------------------------------------------------------------*/
  1141.    /* Local Variables                                                */
  1142.    /*----------------------------------------------------------------*/
  1143. void *tempKeyBrdMsg;
  1144. MYQUEUE Message;
  1145. KEYBRD_MESSAGE *KeyBrdMsg;
  1146. /*----------------------------------------------------------------*/
  1147.    /* Code Body                                                      */
  1148.    /*----------------------------------------------------------------*/
  1149. /* MessageBeep(0xFFFFFFFF); */
  1150. Message.oslSrcId = 0xFFFF;
  1151. Message.oslDestId = MOD_PRT;
  1152. Message.oslMsgId = WM_KEYUP;
  1153. /* OslFreeDataPtr(Message.oslDataPtr); */
  1154. tempKeyBrdMsg = OslConstructDataPtr(sizeof(KEYBRD_MESSAGE));
  1155. KeyBrdMsg = (KEYBRD_MESSAGE *)tempKeyBrdMsg;
  1156. /* KeyBrdMsg = (KEYBRD_MESSAGE *)OslConstructDataPtr(sizeof(KEYBRD_MESSAGE)); */
  1157. KeyBrdMsg->nKeyCode = wParam;
  1158. Message.oslDataPtr = KeyBrdMsg;
  1159.    DebugInfo("shortcut keyup code              %d n", KeyBrdMsg->nKeyCode);
  1160.    if (writeKeyMsgOnCondition(&Message) != TRUE)
  1161.       OslFreeDataPtr(tempKeyBrdMsg);
  1162. } /* keyup_by_shortcut */
  1163. /*****************************************************************************
  1164. * FUNCTION
  1165. *  keydown_by_shortcut
  1166. * DESCRIPTION
  1167. *  function for key down
  1168. *
  1169. * PARAMETERS
  1170. * hWnd IN window handle
  1171. * wParam IN wParam
  1172. * RETURNS
  1173. *  void
  1174. * GLOBALS AFFECTED
  1175. *  void
  1176. *****************************************************************************/
  1177. void keydown_by_shortcut(HWND hWnd, int wParam)
  1178. {
  1179. /*----------------------------------------------------------------*/
  1180.    /* Local Variables                                                */
  1181.    /*----------------------------------------------------------------*/
  1182. void *tempKeyBrdMsg;
  1183. MYQUEUE Message;
  1184. KEYBRD_MESSAGE *KeyBrdMsg;
  1185. /*----------------------------------------------------------------*/
  1186.    /* Code Body                                                      */
  1187.    /*----------------------------------------------------------------*/
  1188. MessageBeep(0xFFFFFFFF);
  1189. Message.oslSrcId = 0xFFFF;
  1190. Message.oslDestId = MOD_PRT;
  1191. Message.oslMsgId = WM_KEYDOWN;
  1192. /* OslFreeDataPtr(Message.oslDataPtr); */
  1193. tempKeyBrdMsg = OslConstructDataPtr(sizeof(KEYBRD_MESSAGE));
  1194. KeyBrdMsg = (KEYBRD_MESSAGE *)tempKeyBrdMsg;
  1195. /* KeyBrdMsg = (KEYBRD_MESSAGE *)OslConstructDataPtr(sizeof(KEYBRD_MESSAGE)); */
  1196. KeyBrdMsg->nKeyCode = wParam;
  1197. Message.oslDataPtr = KeyBrdMsg;
  1198.    DebugInfo("shortcut keydown code %d n", KeyBrdMsg->nKeyCode);
  1199.    if (writeKeyMsgOnCondition(&Message) != TRUE)
  1200.       OslFreeDataPtr(tempKeyBrdMsg);
  1201. } /* end of keydown_by_shortcut */
  1202. /*****************************************************************************
  1203. * FUNCTION
  1204. *  mouse_move_enable
  1205. * DESCRIPTION
  1206. *  function for key down (used for the compatibility of MNT_UI)
  1207. *
  1208. * PARAMETERS
  1209. * hWnd IN window handle
  1210. * xPos IN X position of the mouse
  1211. * yPos IN Y position of the mouse
  1212. * RETURNS
  1213. *  void
  1214. * GLOBALS AFFECTED
  1215. *  void
  1216. *****************************************************************************/
  1217. void mouse_move_enable(HWND hWnd, int xPos, int yPos)
  1218. {
  1219. /*----------------------------------------------------------------*/
  1220.    /* Local Variables                                                */
  1221.    /*----------------------------------------------------------------*/
  1222. /*----------------------------------------------------------------*/
  1223.    /* Code Body                                                      */
  1224.    /*----------------------------------------------------------------*/
  1225. #if defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)
  1226. TouchScreenSimButtonMove();
  1227. #endif /* __MMI_TOUCH_SCREEN__ */
  1228. } /* end of mouse_move_enable */
  1229. /*****************************************************************************
  1230. * FUNCTION
  1231. *  key_detect_ind
  1232. * DESCRIPTION
  1233. *  used for the compatibility of MNT_UI
  1234. *
  1235. * PARAMETERS
  1236. * key_status IN key status
  1237. * key_code IN key code
  1238. * RETURNS
  1239. *  void
  1240. * GLOBALS AFFECTED
  1241. *  void
  1242. *****************************************************************************/
  1243. void key_detect_ind(unsigned char key_status, unsigned char key_code)
  1244. {
  1245. /*----------------------------------------------------------------*/
  1246.    /* Local Variables                                                */
  1247.    /*----------------------------------------------------------------*/
  1248. /*----------------------------------------------------------------*/
  1249.    /* Code Body                                                      */
  1250.    /*----------------------------------------------------------------*/
  1251. } /* end of key_detect_ind */
  1252. /*****************************************************************************
  1253. * FUNCTION
  1254. *  charger_inout
  1255. * DESCRIPTION
  1256. *  used for the compatibility of MNT_UI
  1257. *
  1258. * PARAMETERS
  1259. * void
  1260. * RETURNS
  1261. *  void
  1262. * GLOBALS AFFECTED
  1263. *  void
  1264. *****************************************************************************/
  1265. void charger_inout(void)
  1266. {
  1267. /*----------------------------------------------------------------*/
  1268.    /* Local Variables                                                */
  1269.    /*----------------------------------------------------------------*/
  1270. /*----------------------------------------------------------------*/
  1271.    /* Code Body                                                      */
  1272.    /*----------------------------------------------------------------*/
  1273. /* used for __CUSTOMER_LEVEL_1_RELEASE__ power on in DLL_UI */
  1274. automatic_power_on();
  1275. } /* end of charger_inout */
  1276. /*****************************************************************************
  1277. * FUNCTION
  1278. *  incoming_call
  1279. * DESCRIPTION
  1280. *  used for the compatibility of MNT_UI
  1281. *
  1282. * PARAMETERS
  1283. * void
  1284. * RETURNS
  1285. *  void
  1286. * GLOBALS AFFECTED
  1287. *  void
  1288. *****************************************************************************/
  1289. void incoming_call(void)
  1290. {
  1291. /*----------------------------------------------------------------*/
  1292.    /* Local Variables                                                */
  1293.    /*----------------------------------------------------------------*/
  1294. /*----------------------------------------------------------------*/
  1295.    /* Code Body                                                      */
  1296.    /*----------------------------------------------------------------*/
  1297. } /* end of incoming_call */
  1298. /*****************************************************************************
  1299. * FUNCTION
  1300. *  draw_main_bitmap
  1301. * DESCRIPTION
  1302. *  draw main bitmap
  1303. *
  1304. * PARAMETERS
  1305. * hdc IN    dc handle
  1306. * RETURNS
  1307. *  void
  1308. * GLOBALS AFFECTED
  1309. *  void
  1310. *****************************************************************************/
  1311. void draw_main_bitmap(HDC hdc)
  1312. {
  1313. /*----------------------------------------------------------------*/
  1314.    /* Local Variables                                                */
  1315.    /*----------------------------------------------------------------*/
  1316. /*----------------------------------------------------------------*/
  1317.    /* Code Body                                                      */
  1318.    /*----------------------------------------------------------------*/
  1319. FeedBackFeelingKeyAction(-1);
  1320. } /* end of draw_main_bitmap */
  1321. /*****************************************************************************
  1322. * FUNCTION
  1323. *  launch_nw_simulator
  1324. * DESCRIPTION
  1325. *  launch the network simulator
  1326. *
  1327. * PARAMETERS
  1328. * void
  1329. * RETURNS
  1330. *  void
  1331. * GLOBALS AFFECTED
  1332. *  void
  1333. *****************************************************************************/
  1334. void launch_nw_simulator(void)
  1335. {
  1336. /*----------------------------------------------------------------*/
  1337.    /* Local Variables                                                */
  1338.    /*----------------------------------------------------------------*/
  1339. /*----------------------------------------------------------------*/
  1340.    /* Code Body                                                      */
  1341.    /*----------------------------------------------------------------*/
  1342. #ifndef __CUSTOMER_LEVEL_1_RELEASE__
  1343. if (bFlagNWSimulatorStart)
  1344. {
  1345. NWSimEngine.ShowSimulator();
  1346. }
  1347. else
  1348. {
  1349. bFlagNWSimulatorStart = TRUE;
  1350. NWSimEngine.SetReadQueueHandler(OslReceiveMsgExtQ);
  1351. NWSimEngine.SetWriteQueueHandler(OslMsgSendExtQueue);
  1352.       /* task_info_g1[10] is NW-simulator queue
  1353.          task_info_g1[11] is MMI queue.          */
  1354. NWSimEngine.SetReadQueueHandle(task_info_g1[10].task_ext_qid);
  1355. NWSimEngine.SetWriteQueueHandle(task_info_g1[MOD_PRT].task_ext_qid);
  1356. NWSimEngine.InitSimulator();
  1357. }
  1358. #endif /* __CUSTOMER_LEVEL_1_RELEASE__ */
  1359. } /* end of launch_nw_simulator */
  1360. /*****************************************************************************
  1361. * FUNCTION
  1362. *  shutdown_system_operation
  1363. * DESCRIPTION
  1364. *  shutdown system operation
  1365. *
  1366. * PARAMETERS
  1367. * void
  1368. * RETURNS
  1369. *  void
  1370. * GLOBALS AFFECTED
  1371. *  void
  1372. *****************************************************************************/
  1373. void shutdown_system_operation(void)
  1374. {
  1375. /*----------------------------------------------------------------*/
  1376.    /* Local Variables                                                */
  1377.    /*----------------------------------------------------------------*/
  1378. /*----------------------------------------------------------------*/
  1379.    /* Code Body                                                      */
  1380.    /*----------------------------------------------------------------*/
  1381. #ifdef USING_DLL_UI
  1382. ShutdownSystemOperation();
  1383. #ifndef __CUSTOMER_LEVEL_1_RELEASE__
  1384.    if (bFlagNWSimulatorStart == TRUE)
  1385. NWSimEngine.SendShutDownMsg();
  1386. #endif
  1387. #endif
  1388. } /* end of shutdown_system_operation */
  1389. /*****************************************************************************
  1390. * FUNCTION
  1391. *  on_timer
  1392. * DESCRIPTION
  1393. *  Message handler for WM_TIMER
  1394. *
  1395. * PARAMETERS
  1396. * id IN id
  1397. * RETURNS
  1398. *  void
  1399. * GLOBALS AFFECTED
  1400. *  void
  1401. *****************************************************************************/
  1402. void on_timer(unsigned int id)
  1403. {
  1404. /*----------------------------------------------------------------*/
  1405.    /* Local Variables                                                */
  1406.    /*----------------------------------------------------------------*/
  1407.    MYQUEUE Message;
  1408.     void *temp;
  1409.     TIMER_MESSAGE *timerMsg;
  1410. /*----------------------------------------------------------------*/
  1411.    /* Code Body                                                      */
  1412.    /*----------------------------------------------------------------*/
  1413.   Message.oslSrcId = 0xFFFF;
  1414. Message.oslDestId = MOD_PRT;
  1415. Message.oslMsgId = PRT_MMI_TIMER_IND;
  1416. temp = OslConstructDataPtr(sizeof(TIMER_MESSAGE));
  1417.     timerMsg =(TIMER_MESSAGE *)temp;
  1418. timerMsg->id = id;
  1419. Message.oslDataPtr = timerMsg;
  1420.   OslMsgSendExtQueue(&Message);
  1421. } /* end of on_timer */
  1422. /*****************************************************************************
  1423. * FUNCTION
  1424. *  automatic_power_on
  1425. * DESCRIPTION
  1426. *  power on the phone automatically
  1427. *
  1428. * PARAMETERS
  1429. * void
  1430. * RETURNS
  1431. *  void
  1432. * GLOBALS AFFECTED
  1433. *  void
  1434. *****************************************************************************/
  1435. void automatic_power_on(void)
  1436. {
  1437. /*----------------------------------------------------------------*/
  1438.    /* Local Variables                                                */
  1439.    /*----------------------------------------------------------------*/
  1440. /*----------------------------------------------------------------*/
  1441.    /* Code Body                                                      */
  1442.    /*----------------------------------------------------------------*/
  1443. #if defined(__CUSTOMER_LEVEL_1_RELEASE__)
  1444. if(is_first_bootup)
  1445. {
  1446. SetTimer(0, 0, 1000, AutomaticBoopup);
  1447. is_first_bootup = FALSE;
  1448. }
  1449. #endif
  1450. } /* end of automatic_power_on */
  1451. static int keyDownUpCount = 0;
  1452. /* for debugging */
  1453. static int  keyNumSkipped = 0;
  1454. /*****************************************************************************
  1455. * FUNCTION
  1456. *  writeKeyMsgOnCondition
  1457. * DESCRIPTION
  1458. *  If message queue is not too crowed, write key message. Also onsider key up pairing.
  1459. *
  1460. * PARAMETERS
  1461. * void
  1462. * RETURNS
  1463. *  wrote to queue or not
  1464. *  
  1465. * GLOBALS AFFECTED
  1466. *  void
  1467. *****************************************************************************/
  1468. BOOL writeKeyMsgOnCondition(MYQUEUE *Message)
  1469. {
  1470. /*----------------------------------------------------------------*/
  1471.    /* Local Variables                                                */
  1472.    /*----------------------------------------------------------------*/
  1473.    BOOL        toSend = TRUE;
  1474.    U16         num;
  1475. /*----------------------------------------------------------------*/
  1476.    /* Code Body                                                      */
  1477.    /*----------------------------------------------------------------*/
  1478.    /* check sending critera */
  1479.    num = OslNumOfQMsgs();
  1480.    // work around by decreasing key message number in queue
  1481.    if ((num < (MAX_PRT_NODES/4.0)) ||
  1482.       ((keyDownUpCount < 0) && ((Message->oslMsgId == WM_KEYUP) || (Message->oslMsgId == WM_LBUTTONUP))))
  1483.    {
  1484.       toSend = TRUE;
  1485.    }
  1486.    else
  1487.    {
  1488.       toSend = FALSE;
  1489.    }
  1490.    /* send the msg */
  1491.    if (toSend == TRUE)
  1492.    {
  1493.       if ((Message->oslMsgId != WM_KEYUP) && (Message->oslMsgId != WM_LBUTTONUP))
  1494.          keyDownUpCount ++;
  1495.       else
  1496.          keyDownUpCount --;
  1497.       OslMsgSendExtQueue(Message);
  1498.       return TRUE;
  1499.    }
  1500.    else
  1501.    {
  1502.      DebugInfo("writeKeyMsgOnCondition return FALSE.  num %d n", num);
  1503.       keyNumSkipped ++;
  1504.       return FALSE;
  1505.    }
  1506. }
  1507. #endif /* MMI_ON_WIN32 */
  1508. #endif /* _MMI_CPP */