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

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.  * Filename:
  37.  * ---------
  38.  *  WriteRes.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *  MAUI
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  
  47.  *
  48.  * Author:
  49.  * -------
  50.  *  
  51.  *
  52.  *==============================================================================
  53.  *             HISTORY
  54.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  55.  *------------------------------------------------------------------------------
  56.  * removed!
  57.  *
  58.  * removed!
  59.  * removed!
  60.  * removed!
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * removed!
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * removed!
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * removed!
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * removed!
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * removed!
  81.  *
  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.  *
  106.  * removed!
  107.  * removed!
  108.  * removed!
  109.  *
  110.  * removed!
  111.  * removed!
  112.  * removed!
  113.  *
  114.  * removed!
  115.  * removed!
  116.  * removed!
  117.  *
  118.  * removed!
  119.  * removed!
  120.  * removed!
  121.  *
  122.  * removed!
  123.  * removed!
  124.  * removed!
  125.  *
  126.  * removed!
  127.  * removed!
  128.  * removed!
  129.  *
  130.  * removed!
  131.  * removed!
  132.  * removed!
  133.  *
  134.  * removed!
  135.  * removed!
  136.  * removed!
  137.  *
  138.  * removed!
  139.  * removed!
  140.  * removed!
  141.  *
  142.  *------------------------------------------------------------------------------
  143.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
  144.  *==============================================================================
  145.  *******************************************************************************/
  146. /**
  147.  * Copyright Notice
  148.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  149.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  150.  *  (It is illegal to remove this copyright notice from this software or any
  151.  *  portion of it)
  152.  */
  153. /**********************************************************************************
  154.    FILENAME : WriteRes.c
  155.    PURPOSE     : Helper Functions   to Write/Generate the Customizable Resources like Strings,Images,MenuItems..etc. 
  156.    REMARKS     : nil
  157.    AUTHOR      : Subramanya BG 
  158.    DATE     : 20thSept 2002.
  159.    Copyright (c) 2002 All rights reserved by Pixtel Communications
  160. **********************************************************************************/
  161. #include "GlobalMenuItems.h"
  162. #include "buildcfg.h"
  163. #include "pixteldatatypes.h"
  164. #include "CustDataRes.h"
  165. #include "CustDataProts.h"
  166. #include "CustMenuRes.h"
  167. #include "mmi_features.h"//070306 Alpha layer
  168. #include <string.h>
  169. #include <stdio.h>
  170. #include <stdarg.h>
  171. #include "OslMemory.h"
  172. // #include "UCS2prot.h"
  173. #include "Unicodexdcl.h"
  174. #include "CustResDef.h"
  175. #include "gui.h"
  176. #define MAX_NAME_LENGTH             100
  177. #define MENUITEM_ID_TYPE            9
  178. #define PARENT_ITEM_ID_TYPE            8
  179. #define NUMBER_OF_MENUITEMS_TYPE    7
  180. #define MENU_ITEM_ORDER_TYPE        6
  181. #define  HIDE_FLAG_TYPE             5
  182. #define MOVEABLE_FLAG_TYPE          4
  183. #define  DISPLAY_ATTRIBUTE_TYPE        3
  184. #define  MENU_ITEM_STRING_ID_TYPE      2
  185. #define  MENU_ITEM_IMAGE_ID_TYPE       1
  186. #define TRUE                     1
  187. #define FALSE                    0
  188. #define IMAGE_DESCRIPTOR_SIZE       2
  189. #define  BUFFER_SIZE             4096
  190. #define  BUFFER_SIZE1               16
  191. /* MTK added by JL */
  192. #define   OUTPUT_DATA_FILENAME "..\..\Customer\CustResource\CustImgDataHW.h"
  193. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  194. #define   OUTPUT_DATA_FILENAME_EXT "..\..\Customer\CustResource\CustImgDataHWExt.h" /* 040805 CustPack: Calvin added */
  195. /* __CUSTPACK_MULTIBIN Calvin END */
  196. #define  OUTPUT_MENUTREE_FILENAME "..\..\Customer\CustResource\CustMenuTree_Out.c"
  197. #define  OUTPUT_IMAGE_NAMES_END "[]=n{"
  198. #define  NOIMAGE_FILENAMEBUFFER "..\\..\\Customer\\IMAGES\\NOIMAGE.BMP"
  199. #define  DEFAULT_FILENAMEBUFFER "..\..\Customer\Images\Default.bmp"
  200. #define     DEFAULT_FILEBUFFER         "________CUSTOMER__IMAGES__DEFAULT_BMP"
  201. /* 101205 audio resource Calvin Satrt */
  202. #define   AUDIO_OUTPUT_DATA_FILENAME "..\..\Customer\CustResource\CustAdoDataHW.h"
  203. #define   AUDIO_OUTPUT_DATA_FILENAME_EXT "..\..\Customer\CustResource\CustAdoDataHWExt.h"
  204. #define  OUTPUT_AUDIO_NAMES_END "[]=n{"
  205. #define  NOAUDIO_FILENAMEBUFFER "..\\..\\Customer\\AUDIO\\NOAUDIO.MP3"
  206. #define  AUDIO_DEFAULT_FILENAMEBUFFER "..\..\Customer\Audio\Default.mp3"
  207. #define  AUDIO_DEFAULT_FILEBUFFER         "________CUSTOMER__AUDIO__DEFAULT_MP3"
  208. /* 101205 audio resource Calvin End */
  209. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  210. #define ENFB_IMAGE_DATA_FILENAME  "..\..\Customer\CustResource\CustENFBImgData"//100206 ENFB support
  211. #endif
  212. #ifdef MMI_ON_WIN32
  213. #include <stdafx.h>
  214. #endif 
  215. /* 101205 audio resource Calvin move tp PixtelDataType.h */
  216. #if 0
  217. /* under construction !*/
  218. /* under construction !*/
  219. /* under construction !*/
  220. /* under construction !*/
  221. /* under construction !*/
  222. /* under construction !*/
  223. #endif /* 0 */ 
  224. image_type_enum ExtImageFlag = SYSTEM_IMAGE;
  225. // __CUSTPACK_MULTIBIN Calvin BEGIN
  226. //BOOL ExtImageFlag=FALSE; //040805 CustPack: Calvin added for distinguish which set of images is populated
  227. // __CUSTPACK_MULTIBIN Calvin END
  228. /* 101205 audio resource Calvin Satrt */
  229. BOOL ExtAudioFlag = FALSE;
  230. /* 101205 audio resource Calvin End */
  231. #ifdef DEVELOPER_BUILD_FIRST_PASS
  232. static U8 is_first = 1;
  233. static U32 image_idx = 1;
  234. /* 101205 audio resource Calvin Satrt */
  235. static U32 audio_idx = 1;
  236. /* 101205 audio resource Calvin End */
  237. void Extract_Name(S8 *dest, S8 *src, U32 res_type);
  238. MMI_BOOL Iload(S8 *string, U16 *pType);
  239. extern CUSTOM_STRING *gpStringRes;
  240. extern CUSTOM_STRING_MAP *gpStringMapRes;
  241. /* MTK Leo add, to generate String list in first build. */
  242. extern FILE *StringListFile;
  243. extern FILE *EnumListFile;
  244. /* MTK Leo add,20040318, for new ResGenerator */
  245. U8 StrIsPopulate[MAX_STRING_MAP_SIZE];
  246. //MTK Leo end
  247. //MTK end
  248. /* 091004 MTK Calvin added to reduce populate time */
  249. extern FILE *OutputImgIDFile;
  250. extern FILE *OutputMenutreeIDFile;
  251. extern FILE *RepeatIDListFile;  /* 102604 MTK Calvin added */
  252. /* MTK Calvin end */
  253. /* 101806 E-NFB start */
  254. #include "ImageGetDimension.h"
  255. /* 101806 E-NFB end */
  256. #define _POPULATE_RES_C
  257. S32 g_ressize = 0;
  258. S8 g_resmenu_filename[MAX_FILENAME_LEN] = "";
  259. #ifdef _POPULATE_RES_C
  260. extern mmi_resource_base_struct g_mmi_resource_base_table[];
  261. extern FILE *fpMenuResourceUsage;
  262. extern FILE *fpImageResourceUsage;
  263. extern FILE *fpAudioResourceUsage;
  264. extern FILE *fpStringResourceUsage;
  265. U32 g_resimg_count = 0;
  266. U32 g_resado_count = 0;
  267. CUSTOM_RESOURCE_SIZE g_resimg_table[MAX_IMAGE_IDS_SIZE];
  268. CUSTOM_RESOURCE_SIZE g_resado_table[MAX_AUDIO_IDS_SIZE];
  269. #endif /* _POPULATE_RES_C */
  270. /* decalred in the CustImageRes.c */
  271. extern CUSTOM_IMAGE nCustImageNames[];
  272. extern IMAGENAME_LIST ImageNameList[];
  273. extern CUSTOM_IMAGE_MAP ImageIdMap[];
  274. extern CUSTOM_IMAGE_SEARCH_MAP ImageIdSearchMap[];
  275. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  276. /* 040805 CustPack: Calvn added */
  277. extern IMAGENAME_LIST ImageNameListEXT[];
  278. extern CUSTOM_IMAGE_MAP ImageIdMapEXT[];
  279. extern CUSTOM_IMAGE_SEARCH_MAP ImageIdSearchMapEXT[];
  280. /* Calvin end */
  281. /* __CUSTPACK_MULTIBIN Calvin END */
  282. /* 101205 audio resource Calvin Satrt */
  283. extern FILE *OutputAdoIDFile;
  284. /* decalred in the CustAudioRes.c */
  285. extern CUSTOM_AUDIO nCustAudioNames[];
  286. extern AUDIONAME_LIST AudioNameList[];
  287. extern CUSTOM_AUDIO_MAP AudioIdMap[];
  288. extern CUSTOM_AUDIO_SEARCH_MAP AudioIdSearchMap[];
  289. extern AUDIONAME_LIST AudioNameListEXT[];
  290. extern CUSTOM_AUDIO_MAP AudioIdMapEXT[];
  291. extern CUSTOM_AUDIO_SEARCH_MAP AudioIdSearchMapEXT[];
  292. /* 101205 audio resource Calvin End */
  293. /* decalred in the CustScreenData.c */
  294. extern CUSTOM_SCREEN nCustScreens[MAX_SCREEN_IDS];
  295. /* declared in the CustMenuDataRes.c */
  296. #ifdef MMI_ON_HARDWARE_P
  297. extern const CUSTOM_MENU nCustMenus[MAX_MENU_ITEMS];
  298. #else 
  299. extern CUSTOM_MENU nCustMenus[MAX_MENU_ITEMS];
  300. #endif 
  301. /* Global Variables */
  302. /* 101205 audio resource Calvin Satrt */
  303. S8 filename_buffer[BUFFER_SIZE];
  304. S8 tempBMPFile[BUFFER_SIZE];//070306 Alpha layer
  305. S8 autofilename_buffer[BUFFER_SIZE];
  306. S8 number_string[BUFFER_SIZE1];
  307. S8 autoimagename_buffer[BUFFER_SIZE];
  308. FILE *output_data_file;
  309. FILE *image_data_file;
  310. FILE *nfb_img_res_file;
  311. S8 *output_image_names = NULL;
  312. S32 n_supported_extensions = 1;
  313. FILE *audio_data_file;
  314. S8 *output_audio_names = NULL;
  315. /* 101205 audio resource Calvin End */
  316. /* 120704 Calvin added */
  317. #define SUPPORT_N_MEDIA_TYPE     3
  318. S8 *support_media_ext[SUPPORT_N_MEDIA_TYPE] = { "AVI", "3GP", "MP4" };
  319. /* Calvin end */
  320. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  321. /* 040805 CustPack: Calvin added */
  322. FILE *dest_file;
  323. int toolFlag = 0;       /* decide if this is run by CustPack tool */
  324. int resultFailFlag = 0; /* decide if this is run by CustPack tool */
  325. /* Calvin end */
  326. /* __CUSTPACK_MULTIBIN Calvin END */
  327. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  328. FILE *enfb_img_data_file;//100206 ENFB support
  329. int enfbFlag = 0;
  330. int disableENFB = 0;
  331. U32 enfb_offset = 0;
  332. U32 enfb_size = 0;
  333. #endif
  334. /* 101205 audio resource Calvin modifiied */
  335. typedef struct Resource_Info
  336. {
  337.     S8 *filename_ext;
  338.     U8 file_type;
  339. } RESOURCE_INFO;
  340. #define MAX_SEQUENTIAL_IMAGE_FRAME        512
  341. #define SUPPORT_N_SEQUENTIAL_IMAGE_TYPE      3
  342. RESOURCE_INFO sequential_image[SUPPORT_N_SEQUENTIAL_IMAGE_TYPE] = { {"BMP", IMAGE_TYPE_BMP_SEQUENCE},
  343. {"JPG", IMAGE_TYPE_JPG_SEQUENCE},
  344. {"PNG", IMAGE_TYPE_PNG_SEQUENCE}
  345. };  /* 101205 audio resource Calvin */
  346. RESOURCE_INFO image_resource_info[] = 
  347. {
  348.     {"BMP", IMAGE_TYPE_BMP},
  349.     {"PBM", IMAGE_TYPE_DEVICE_BITMAP},//070306 Alpha layer
  350.     {"GIF", IMAGE_TYPE_GIF},
  351.     {"JPG", IMAGE_TYPE_JPG},
  352.     {"AVI", IMAGE_TYPE_AVI},
  353.     {"3GP", IMAGE_TYPE_3GP},
  354.     {"MP4", IMAGE_TYPE_MP4},
  355.     {"PNG", IMAGE_TYPE_PNG},
  356.     {"PPN", IMAGE_TYPE_PPN},//070306 Alpha layer
  357.     {"M3D", IMAGE_TYPE_M3D},
  358.     {"CMP", IMAGE_TYPE_SWFLASH}
  359. };
  360. RESOURCE_INFO audio_resource_info[] = { {"MP3", AUDIO_TYPE_MP3},
  361. {"IMY", AUDIO_TYPE_IMY},
  362. {"MID", AUDIO_TYPE_MID},
  363. {"WAV", AUDIO_TYPE_WAV},
  364. {"MMF", AUDIO_TYPE_MMF},
  365. {"PCM", AUDIO_TYPE_PCM},
  366. {"DVI", AUDIO_TYPE_DVI},
  367. {"AMR", AUDIO_TYPE_AMR},
  368. {"AAC", AUDIO_TYPE_AAC},
  369. {"WMA", AUDIO_TYPE_WMA},
  370. {"M4A", AUDIO_TYPE_M4A}
  371. };
  372. /* 101205 audio resource Calvin end */
  373. S32 sequential_interval[MAX_SEQUENTIAL_IMAGE_FRAME];
  374. S32 sequential_filesize[MAX_SEQUENTIAL_IMAGE_FRAME];
  375. S32 sequential_offset[MAX_SEQUENTIAL_IMAGE_FRAME];
  376. S32 sequential_extension_type;  /* 031705 Calvin modified */
  377. S32 sequential_frame;
  378. /* Calvin end */
  379. extern S8 CustImgPath[];
  380. extern S8 CustAdoPath[];    /* 101205 audio resource Calvin Add */
  381. #ifdef __UCS2_ENCODING
  382. U16 AnsiiToUnicodeString(S8 *pOutBuffer, S8 *pInBuffer);
  383. #endif 
  384. extern HWND hWnd;
  385. U16 CurrMaxStringId;
  386. extern U16 CurrMaxImageNum;
  387. extern U16 CurrMaxImageId;
  388. extern U16 CurrMaxMenuItemIndex;
  389. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  390. /* 040805 CustPack: Calvin added */
  391. extern U16 CurrMaxImageNumEXT;
  392. extern U16 CurrMaxImageIdEXT;
  393. /* Calvin end */
  394. /* __CUSTPACK_MULTIBIN Calvin END */
  395. /* 101205 audio resource Calvin Satrt */
  396. extern U16 CurrMaxAudioNum;
  397. extern U16 CurrMaxAudioId;
  398. extern U16 CurrMaxAudioNumEXT;
  399. extern U16 CurrMaxAudioIdEXT;
  400. /* 101205 audio resource Calvin End */
  401. #ifdef __POPULATE_ENGINE_
  402. void AddStringInfo(int StrId, char *pString, char *pStringDisplay);
  403. void AddImageInfo(int ImgId, char *pImage, char *pIMageDisplay);
  404. void AddApplicationInfo(U32 nId, S8 *pName, U32 nMinId, U32 nMaxId);
  405. #endif /* __POPULATE_ENGINE_ */ 
  406. /* 101806 E-NFB start */
  407. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  408. MMI_BOOL ENFBAssociatedIDFlag = MMI_FALSE;
  409. MMI_BOOL ENFBAssociatedIDAdded = MMI_FALSE;
  410. extern unsigned short CurrMaxENFBAssociatedIDNum;
  411. extern CUSTOM_ENFB_STR ENFBAssociatedIDList[];
  412. #endif
  413. /* 101806 E-NFB end */
  414. /* 101806 E-NFB start */
  415. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  416. /*****************************************************************************
  417.  * FUNCTION
  418.  *  SetENFBAssociatedID
  419.  * DESCRIPTION
  420.  *  start to record associated ID list
  421.  * PARAMETERS
  422.  *  void
  423.  * RETURNS
  424.  *  MMI_BOOL MMI_TRUE or MMI_FALSE
  425.  *****************************************************************************/
  426. MMI_BOOL SetENFBAssociatedID(void)
  427. {
  428. /*----------------------------------------------------------------*/
  429. /* Local Variables                                                */
  430. /*----------------------------------------------------------------*/
  431. /*----------------------------------------------------------------*/
  432. /* Code Body                                                      */
  433. /*----------------------------------------------------------------*/
  434. /* if flag = false, set flag = true, allocate memory, and no++ */
  435. if (ENFBAssociatedIDFlag == MMI_FALSE)
  436. {
  437. CUSTOM_ENFB_STR *enfb;
  438.         int str_size = 256;
  439. int i;
  440. ENFBAssociatedIDFlag = MMI_TRUE;
  441. CurrMaxENFBAssociatedIDNum++;
  442. enfb = &ENFBAssociatedIDList[CurrMaxENFBAssociatedIDNum];
  443. enfb->count = 0;
  444. enfb->IDs = (U16 *)malloc(MAX_ASSOCIATED_LIST_IDS*sizeof(U16));
  445. enfb->Ptr = (S8 **)malloc(MAX_ASSOCIATED_LIST_IDS*sizeof(S8*));
  446. for (i = 0; i < MAX_ASSOCIATED_LIST_IDS ; i++)
  447. {
  448. enfb->Ptr[i] = (S8 *)malloc(str_size*sizeof(S8));
  449. }
  450. return MMI_TRUE;
  451. }
  452. /* error: cannot set flag twice */
  453. else
  454. {
  455. return MMI_FALSE;
  456. }
  457. }
  458. /*****************************************************************************
  459.  * FUNCTION
  460.  *  AddENFBAssociatedIDItem
  461.  * DESCRIPTION
  462.  *  add item to current associated list
  463.  * PARAMETERS
  464.  *  ImageID [IN]
  465.  *  filename [IN]
  466.  * RETURNS
  467.  *  MMI_BOOL MMI_TRUE or MMI_FALSE
  468.  *****************************************************************************/
  469. MMI_BOOL AddENFBAssociatedIDItem(U16 ImageID, S8 *filename, U32 type)
  470. {
  471. /*----------------------------------------------------------------*/
  472. /* Local Variables                                                */
  473. /*----------------------------------------------------------------*/
  474. /*----------------------------------------------------------------*/
  475. /* Code Body                                                      */
  476. /*----------------------------------------------------------------*/
  477. /* if flag = true, record this item: imagd ID & pointer variable */
  478. if (ENFBAssociatedIDFlag == MMI_TRUE)
  479. {
  480. CUSTOM_ENFB_STR *enfb;
  481.         int i;
  482. enfb = &ENFBAssociatedIDList[CurrMaxENFBAssociatedIDNum];
  483. enfb->IDs[enfb->count] = ImageID;
  484. Extract_Name(enfb->Ptr[enfb->count], filename, type);
  485.         for (i = 0; i < strlen(enfb->Ptr[enfb->count]); i++)
  486.         {
  487.             enfb->Ptr[enfb->count][i] = toupper(enfb->Ptr[enfb->count][i]);
  488.         }
  489. enfb->count++;
  490. return MMI_TRUE;
  491. }
  492. /* if flag = false, do not record this item */
  493. else
  494. {
  495. return MMI_FALSE;
  496. }
  497. }
  498. /*****************************************************************************
  499.  * FUNCTION
  500.  *  ResetENFBAssociatedID
  501.  * DESCRIPTION
  502.  *  end of one associated ID list
  503.  * PARAMETERS
  504.  *  void
  505.  * RETURNS
  506.  *  MMI_BOOL MMI_TRUE or MMI_FALSE
  507.  *****************************************************************************/
  508. MMI_BOOL ResetENFBAssociatedID(void)
  509. {
  510. /*----------------------------------------------------------------*/
  511. /* Local Variables                                                */
  512. /*----------------------------------------------------------------*/
  513. /*----------------------------------------------------------------*/
  514. /* Code Body                                                      */
  515. /*----------------------------------------------------------------*/
  516. /* if flag = true, set flag = false */
  517. if (ENFBAssociatedIDFlag == MMI_TRUE)
  518. {
  519. ENFBAssociatedIDFlag = MMI_FALSE;
  520. /* if current associated list is empty, reuse it for next list */
  521. if (ENFBAssociatedIDList[CurrMaxENFBAssociatedIDNum].count == 0)
  522. {
  523. CurrMaxENFBAssociatedIDNum--;
  524. }
  525. return MMI_TRUE;
  526. }
  527. /* error: can not set flag = false twice */
  528. else
  529. {
  530. return MMI_FALSE;
  531. }
  532. }
  533. /*****************************************************************************
  534.  * FUNCTION
  535.  *  GetCurrENFBAssociatedID
  536.  * DESCRIPTION
  537.  *  end of one associated ID list
  538.  * PARAMETERS
  539.  *  void
  540.  * RETURNS
  541.  *  U32 current associated ID
  542.  *****************************************************************************/
  543. U16 GetCurrENFBAssociatedID(void)
  544. {
  545. /*----------------------------------------------------------------*/
  546. /* Local Variables                                                */
  547. /*----------------------------------------------------------------*/
  548. /*----------------------------------------------------------------*/
  549. /* Code Body                                                      */
  550. /*----------------------------------------------------------------*/
  551. if (ENFBAssociatedIDFlag == MMI_TRUE)
  552. {
  553.     return CurrMaxENFBAssociatedIDNum;
  554. }
  555. else
  556. {
  557.         return 0;
  558. }
  559. }
  560. /*****************************************************************************
  561.  * FUNCTION
  562.  *  IfItemExistENFBAssociatedID
  563.  * DESCRIPTION
  564.  *  test if the ImageID has already existed in one associated ID list
  565.  * PARAMETERS
  566.  *  ImageID     [IN]
  567.  * RETURNS
  568.  *  MMI_BOOL MMI_TRUE or MMI_FALSE
  569.  *****************************************************************************/
  570. MMI_BOOL IfItemExistENFBAssociatedID(S8 *filename, U32 type)
  571. {
  572. /*----------------------------------------------------------------*/
  573. /* Local Variables                                                */
  574. /*----------------------------------------------------------------*/
  575.     int i, j, k;
  576.     int str_size = 256;
  577. /*----------------------------------------------------------------*/
  578. /* Code Body                                                      */
  579. /*----------------------------------------------------------------*/
  580.     for (i = 1; i <= (int)CurrMaxENFBAssociatedIDNum; i++)
  581.     {
  582. CUSTOM_ENFB_STR *enfb;
  583.         S8 *ptr;
  584. enfb = &ENFBAssociatedIDList[i];
  585.         for (j = 0; j <= (int)enfb->count; j++)
  586.         {
  587.             ptr = (S8 *)malloc(str_size*sizeof(S8));
  588.             Extract_Name(ptr, filename, type);
  589.             for (k = 0; k < strlen(ptr); k++)
  590.             {
  591.                 ptr[k] = toupper(ptr[k]);
  592.             }
  593.             if (strcmp((char *)ptr, (char *)enfb->Ptr[j]) == 0)
  594.             {
  595.                 return MMI_TRUE;
  596.             }
  597.         }
  598.     }
  599.     return MMI_FALSE;
  600. }
  601. #endif
  602. /* 101806 E-NFB end */
  603. #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE)
  604. U32 GetOffsetFromResourceBase(U16 ImageID)
  605. {
  606.     U32 i = 0;
  607.     
  608.     while (1)
  609.     {
  610.         if (strncmp(g_mmi_resource_base_table[i].appname, "END", 3) == 0)
  611.         {
  612.             break;
  613.         }
  614.         else if ((ImageID >= g_mmi_resource_base_table[i].min) &&
  615.                  (ImageID < g_mmi_resource_base_table[i].max))
  616.         {
  617.             return i;
  618.         }
  619.         else
  620.         {
  621.             i++;
  622.         }
  623.     }
  624.     return 0xFFFFFFFF;
  625. }
  626. #define RESPRT(fp, app, base, ID, strID, size, data, resfile)   
  627.     do                                                          
  628.     {                                                           
  629.         fprintf(fp, "%st%dt%dt%st%dt%st%sn",             
  630.                 app, base, ID, strID, size, data, resfile);     
  631.     } while (0)
  632. #define RESPRTONERECORD(fp, nImgId, data, enum_value, resfile)      
  633.     do                                                              
  634.     {                                                               
  635.         if (fp != NULL)                                             
  636.         {                                                           
  637.             U32 offset = GetOffsetFromResourceBase(nImgId);         
  638.             if (offset == 0xFFFFFFFF)                               
  639.             {                                                       
  640.                 RESPRT(fp, "NO_APP", -1, nImgId, enum_value,        
  641.                        g_ressize, data, resfile);                   
  642.             }                                                       
  643.             else                                                    
  644.             {                                                       
  645.                 RESPRT(fp,                                          
  646.                        g_mmi_resource_base_table[offset].appname,   
  647.                        g_mmi_resource_base_table[offset].min,       
  648.                        nImgId, enum_value, g_ressize, data,         
  649.                        resfile);                                    
  650.             }                                                       
  651.         }                                                           
  652.     } while (0)
  653. #endif /* #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE) */
  654. /*****************************************************************************
  655.  * FUNCTION
  656.  *  InitStrPopulate
  657.  * DESCRIPTION
  658.  *  
  659.  * PARAMETERS
  660.  *  void
  661.  * RETURNS
  662.  *  void
  663.  *****************************************************************************/
  664. void InitStrPopulate()
  665. {
  666.     /*----------------------------------------------------------------*/
  667.     /* Local Variables                                                */
  668.     /*----------------------------------------------------------------*/
  669.     int i = 0;
  670.     /*----------------------------------------------------------------*/
  671.     /* Code Body                                                      */
  672.     /*----------------------------------------------------------------*/
  673.     for (i = 0; i < MAX_STRING_MAP_SIZE; i++)
  674.     {
  675.         StrIsPopulate[i] = 0;
  676.     }
  677. }
  678. /* MTK Leo add, to store new string */
  679. /*****************************************************************************
  680.  * FUNCTION
  681.  *  ConvertToPrintable
  682.  * DESCRIPTION
  683.  *  
  684.  * PARAMETERS
  685.  *  original        [?]     
  686.  *  converted       [?]     
  687.  * RETURNS
  688.  *  void
  689.  *****************************************************************************/
  690. void ConvertToPrintable(S8 *original, S8 *converted)
  691. {
  692.     /*----------------------------------------------------------------*/
  693.     /* Local Variables                                                */
  694.     /*----------------------------------------------------------------*/
  695.     U16 i = 0, j = 0, strlength = 0;
  696.     /*----------------------------------------------------------------*/
  697.     /* Code Body                                                      */
  698.     /*----------------------------------------------------------------*/
  699.     strlength = wcslen((wchar_t*) original);
  700.     for (i = 0; i < strlength * 2; i++)
  701.     {
  702.         if (original[i] == 10)
  703.         {
  704.             converted[j] = 92;
  705.             converted[++j] = 0;
  706.             converted[++j] = 'n';
  707.             j++;
  708.         }
  709.         else
  710.         {
  711.             converted[j++] = original[i];
  712.         }
  713.     }
  714.     if (strlength == 0)
  715.     {   /* If NULL string, fill in " " */
  716.         converted[0] = 20;
  717.         converted[1] = '';
  718.         converted[2] = '';
  719.         converted[3] = '';
  720.     }
  721.     else
  722.     {
  723.         converted[j++] = '';
  724.         converted[j] = '';
  725.     }
  726. }
  727. /* MTK Leo end */
  728. /* MTK Leo add, to generate String list in first build. */
  729. /*****************************************************************************
  730.  * FUNCTION
  731.  *  SetStringWithDisplay
  732.  * DESCRIPTION
  733.  *  
  734.  * PARAMETERS
  735.  *  nStrId          [IN]        
  736.  *  pString1        [?]         
  737.  *  pDisplay1       [?]         
  738.  *  enum_value      [?]         
  739.  * RETURNS
  740.  *  void
  741.  *****************************************************************************/
  742. void SetStringWithDisplay(U16 nStrId, S8 *pString1, S8 *pDisplay1, S8 *enum_value, S8 *resfile)
  743. {
  744.     /*----------------------------------------------------------------*/
  745.     /* Local Variables                                                */
  746.     /*----------------------------------------------------------------*/
  747.     U16 i;
  748.     U16 found = 0;
  749.     S8 *pString = NULL;
  750.     S8 *pDisplay = NULL;
  751.     ResourceInfo sInfo;
  752.     S8 *sString = NULL;
  753.     U16 StrTotalLen = 0;
  754.     U16 nLen = 0;
  755.     /* MTK Leo add, to store new string */
  756.     S8 cString[1024], cDisplay[1024];
  757.     S8 *pEnum_value = NULL;
  758.     /*----------------------------------------------------------------*/
  759.     /* Code Body                                                      */
  760.     /*----------------------------------------------------------------*/
  761.     /* MTK Leo end */
  762.     g_ressize = 1;  //strlen(pString1);
  763. #ifdef _POPULATE_RES_C
  764.     if (strstr(pString1, "n") == NULL)
  765.     {
  766.         RESPRTONERECORD(fpStringResourceUsage, nStrId, pString1, enum_value, resfile);
  767.     }
  768.     else
  769.     {
  770.         RESPRTONERECORD(fpStringResourceUsage, nStrId, "N/A", enum_value, resfile);
  771.     }
  772. #endif /* _POPULATE_RES_C */
  773. #ifdef __ASCII
  774.     pString = pString1;
  775.     pDisplay = pDisplay1;
  776. #endif /* __ASCII */ 
  777. #ifdef __UCS2_ENCODING
  778.     pString = OslMalloc((strlen(pString1) + 1) * 2);
  779.     AnsiiToUnicodeString(pString, pString1);
  780.     pDisplay = OslMalloc((strlen(pDisplay1) + 1) * 2);
  781.     AnsiiToUnicodeString(pDisplay, pDisplay1);
  782.     pEnum_value = OslMalloc((strlen(enum_value) + 1) * 2);
  783.     AnsiiToUnicodeString(pEnum_value, enum_value);
  784. #endif /* __UCS2_ENCODING */ 
  785.     /* Leo remove, no need to set limit */
  786.     //      if(CurrMaxStringId >= MAX_STRING_IDS) return;   /* Can't add more than max number of string ids allowed */
  787.     //      if (gpStringMapRes[nStrId]==(U16)-1) 
  788.     if (StrIsPopulate[nStrId] == 0)
  789.     {
  790.         CurrMaxStringId++;
  791.         StrIsPopulate[nStrId] = 1;
  792.         ConvertToPrintable(pString, cString);
  793.         ConvertToPrintable(pDisplay, cDisplay);
  794.         fwprintf(
  795.             StringListFile,
  796.             L"%lst%dt%lst%lsrn",
  797.             (wchar_t*) pEnum_value,
  798.             nStrId,
  799.             (wchar_t*) cDisplay,
  800.             (wchar_t*) cString);
  801.         fprintf(EnumListFile, "%s,n", enum_value);
  802.     }
  803.     else    /* 102604 MTK Calvin added */
  804.     {
  805.         fprintf(RepeatIDListFile, "%dt%stt%sn", nStrId, enum_value, "String");
  806.     }
  807. }
  808. /* MTK Leo end */
  809. /*****************************************************************************
  810.  * FUNCTION
  811.  *  AddApp
  812.  * DESCRIPTION
  813.  *  Function to Add a new application into the framework
  814.  * PARAMETERS
  815.  *  nId         [IN]        App Id
  816.  *  pName       [IN]        Application name.
  817.  *  nMinId      [IN]        Minimum Id value supported
  818.  *  nMaxId      [IN]        Maximum Id value
  819.  * RETURNS
  820.  *  void
  821.  *****************************************************************************/
  822. void AddApp(U32 nId, S8 *pName, U16 nMinId, U16 nMaxId)
  823. {
  824.     /*----------------------------------------------------------------*/
  825.     /* Local Variables                                                */
  826.     /*----------------------------------------------------------------*/
  827.     ResourceInfo sInfo;
  828.     /*----------------------------------------------------------------*/
  829.     /* Code Body                                                      */
  830.     /*----------------------------------------------------------------*/
  831.     sInfo.nAppId = nId;
  832.     sInfo.nMaxId = nMaxId;
  833.     sInfo.nMinId = nMinId;
  834.     sInfo.pValue = pName;
  835. }
  836. /*****************************************************************************
  837.  * FUNCTION
  838.  *  SetString
  839.  * DESCRIPTION
  840.  *  Function to Update the Customizable Resource String & Mapping Array.
  841.  * PARAMETERS
  842.  *  StrId           [IN]        
  843.  *  String1         [?]         
  844.  *  enum_value      [?]         
  845.  *  U16(?)          [OUT]       String Number which is Mapped with the StringId.
  846.  * RETURNS
  847.  *  StringNumber which is mapped with the StringID.(?)
  848.  *****************************************************************************/
  849. /* MTK Leo add, to generate String list in first build. */
  850. void SetString(U16 StrId, S8 *String1, S8 *enum_value, S8 *resfile)
  851. {
  852.     /*----------------------------------------------------------------*/
  853.     /* Local Variables                                                */
  854.     /*----------------------------------------------------------------*/
  855.     /*----------------------------------------------------------------*/
  856.     /* Code Body                                                      */
  857.     /*----------------------------------------------------------------*/
  858.     /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  859.     SetStringWithDisplay(StrId, String1, String1, enum_value, resfile);  /* 040805 CustPack: Calvin revised */
  860.     /* __CUSTPACK_MULTIBIN Calvin END */
  861. }
  862. /* MTK Leo end */
  863. /*****************************************************************************
  864.  * FUNCTION
  865.  *  SetImage
  866.  * DESCRIPTION
  867.  *  Function to Update the Customizable Image Filename & Mapping Array.
  868.  * PARAMETERS
  869.  *  ImgId           [IN]        
  870.  *  filename        [?]         
  871.  *  enum_value      [?]         
  872.  *  res_type        [IN]        
  873.  *  U16(?)          [OUT]       Image Number which is Mapped with the ImageId.
  874.  * RETURNS
  875.  *  Image Number which is mapped with the ImageId.(?)
  876.  *****************************************************************************/
  877. void SetImage(U16 ImgId, S8 *filename, S8 *enum_value, U32 res_type, S8 *resfile)  /* 120304 Calvin modified for media resource */
  878. {
  879.     /*----------------------------------------------------------------*/
  880.     /* Local Variables                                                */
  881.     /*----------------------------------------------------------------*/
  882.     /*----------------------------------------------------------------*/
  883.     /* Code Body                                                      */
  884.     /*----------------------------------------------------------------*/
  885.     /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  886.     SetImageWithBuffer(ImgId, filename, "", enum_value, res_type, FALSE, resfile);       /* 040805 CustPack: Calvin revised */
  887.     /* __CUSTPACK_MULTIBIN Calvin END */
  888. }
  889. /*****************************************************************************
  890.  * FUNCTION
  891.  *  SetNFBImage
  892.  * DESCRIPTION
  893.  *  
  894.  * PARAMETERS
  895.  *  filename        [?]     
  896.  * RETURNS
  897.  *  void
  898.  *****************************************************************************/
  899. void SetNFBImage(S8 *filename)
  900. {
  901.     /*----------------------------------------------------------------*/
  902.     /* Local Variables                                                */
  903.     /*----------------------------------------------------------------*/
  904.     U16 nType;
  905.     S16 nStrlen;
  906.     S8 upperFileName[MAX_FILENAME_LEN];
  907.     /*----------------------------------------------------------------*/
  908.     /* Code Body                                                      */
  909.     /*----------------------------------------------------------------*/
  910.     if (strlen(filename) >= MAX_FILENAME_LEN)
  911.     {
  912.         filename[MAX_FILENAME_LEN - 1] = '';
  913.     }
  914.     if (!(strcmp(filename, "")))
  915.     {
  916.         strcpy(filename_buffer, NOIMAGE_FILENAMEBUFFER);
  917.     }
  918.     nStrlen = strlen(filename);
  919.     while (nStrlen >= 0)
  920.     {
  921.         upperFileName[nStrlen] = toupper(filename[nStrlen]);
  922.         --nStrlen;
  923.     }
  924.     ExtImageFlag = NFB_PROGRESS_IMAGE;
  925. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  926.     disableENFB = 1;//100206 ENFB support
  927. #endif
  928.     Iload(upperFileName, &nType);
  929. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  930.     disableENFB = 0;
  931. #endif
  932. }
  933. /*****************************************************************************
  934.  * FUNCTION
  935.  *  SetImageWithBuffer
  936.  * DESCRIPTION
  937.  *  Function to copy the image file to buffer
  938.  * PARAMETERS
  939.  *  nImgId              [IN]        
  940.  *  filename            [?]         
  941.  *  pDisplayName        [?]         
  942.  *  enum_value          [?]         
  943.  *  res_type            [IN]        
  944.  *  imgFlag             [IN]        
  945.  *  S8(?)               [OUT]       -> filename of the image to be displayed.
  946.  *  U16(?)              [IN]        -> ImageId
  947.  * RETURNS
  948.  *  void
  949.  *****************************************************************************/
  950. void SetImageWithBuffer(U16 nImgId, S8 *filename, S8 *pDisplayName, S8 *enum_value, U32 res_type, BOOL imgFlag, S8 *resfile)      /* 120304 Calvin modified for media resource */
  951. {
  952.     /*----------------------------------------------------------------*/
  953.     /* Local Variables                                                */
  954.     /*----------------------------------------------------------------*/
  955.     U16 i;
  956.     U16 found = 0;
  957.     S16 nStrlen;
  958.     ResourceInfo sInfo;
  959.     U16 nType;
  960.     S8 upperFileName[MAX_FILENAME_LEN];
  961.     unsigned short *pCurrMaxImageId;
  962.     unsigned short *pCurrMaxImageNum;
  963.     IMAGENAME_LIST *pImageNameList;
  964.     CUSTOM_IMAGE_MAP *pImageIdMap;
  965.     /*----------------------------------------------------------------*/
  966.     /* Code Body                                                      */
  967.     /*----------------------------------------------------------------*/
  968.     if (imgFlag == TRUE)
  969.     {
  970.         ExtImageFlag = EXT_IMAGE;
  971.         pCurrMaxImageId = &CurrMaxImageIdEXT;
  972.         pCurrMaxImageNum = &CurrMaxImageNumEXT;
  973.         pImageNameList = ImageNameListEXT;
  974.         pImageIdMap = ImageIdMapEXT;
  975.     #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  976.         #ifdef MULTIPLE_BINARY_FILES
  977.         disableENFB = 1;//100206 ENFB support
  978.         #endif
  979.     #endif
  980.     }
  981.     else
  982.     {
  983.         ExtImageFlag = SYSTEM_IMAGE;
  984.         pCurrMaxImageId = &CurrMaxImageId;
  985.         pCurrMaxImageNum = &CurrMaxImageNum;
  986.         pImageNameList = ImageNameList;
  987.         pImageIdMap = ImageIdMap;
  988.     }
  989.     if (*pCurrMaxImageId >= MAX_IMAGE_IDS_SIZE)
  990.     {
  991.         return; /* Can't add more than max number of image ids allowed */
  992.     }
  993.     fprintf(OutputImgIDFile, "file name%d = %s n", image_idx++, filename);
  994.     if (strlen(filename) >= MAX_FILENAME_LEN)
  995.     {
  996.         filename[MAX_FILENAME_LEN - 1] = '';
  997.     }
  998.     if (!(strcmp(filename, "")))
  999.     {
  1000.         strcpy(filename_buffer, NOIMAGE_FILENAMEBUFFER);
  1001.     }
  1002.     nStrlen = strlen(filename);
  1003.     while (nStrlen >= 0)
  1004.     {
  1005.         upperFileName[nStrlen] = toupper(filename[nStrlen]);
  1006.         --nStrlen;
  1007.     }
  1008.     for (i = 0; i < *pCurrMaxImageNum; i++)
  1009.     {
  1010.         if (!strcmp(pImageNameList[i].filename, upperFileName))
  1011.         {
  1012.             found = 1;
  1013.             break;
  1014.         }
  1015.     }
  1016.     if (pImageIdMap[nImgId].nImageId != 0)  /* 102604 MTK Calvin added */
  1017.     {
  1018.         switch (res_type)
  1019.         {
  1020.             case RES_IMAGE:
  1021.                 fprintf(RepeatIDListFile, "%dt%stt%sn", nImgId, enum_value, "Image");
  1022.                 break;
  1023.             case RES_MEDIA:
  1024.                 fprintf(RepeatIDListFile, "%dt%stt%sn", nImgId, enum_value, "Media");
  1025.                 break;
  1026.             default:
  1027.                 printf("Non supported resource type!n");
  1028.         }
  1029.     }
  1030.     g_ressize = 0;
  1031.     if (found)
  1032.     {
  1033.         pImageIdMap[nImgId].nImageId = nImgId;
  1034.         pImageIdMap[nImgId].nImageNum = i;
  1035.         (*pCurrMaxImageId)++;
  1036.     #ifdef __MMI_RESOURCE_ENFB_SUPPORT__//100206 ENFB support
  1037.         if ((disableENFB == 0) && (ENFBAssociatedIDFlag == MMI_TRUE))
  1038.         {
  1039.             if (IfItemExistENFBAssociatedID(upperFileName, res_type))//already in other associated group
  1040.             {
  1041.                 AddENFBAssociatedIDItem(nImgId, upperFileName, res_type);
  1042.             }
  1043.             else
  1044.             {
  1045.                 fprintf(RepeatIDListFile, "nn!!!!!!!!!!!!%dt%stt%s!!!!!!!!!!!!!nn", nImgId, enum_value, upperFileName);
  1046.             }
  1047.         }
  1048.     #endif
  1049. #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE)
  1050.         {
  1051.             S8 str1[MAX_IMAGE_NAMES_SIZE];
  1052.             S8 str2[MAX_IMAGE_NAMES_SIZE];
  1053.             U32 i, j;
  1054.             strcpy(str1, filename);
  1055.             for (j = 0; j < strlen(str1); j++)
  1056.             {
  1057.                 str1[j] = toupper(str1[j]);
  1058.             }
  1059.             for (i = 0; i < g_resimg_count; i++)
  1060.             {
  1061.                 strcpy(str2, g_resimg_table[i].filename);
  1062.                 for (j = 0; j < strlen(str1); j++)
  1063.                 {
  1064.                     str2[j] = toupper(str2[j]);
  1065.                 }
  1066.                 if (strcmp(str1, str2) == 0)
  1067.                 {
  1068.                     g_ressize = g_resimg_table[i].size;
  1069.                     break;
  1070.                 }
  1071.             }
  1072.         }
  1073.         RESPRTONERECORD(fpImageResourceUsage, nImgId, filename, enum_value, resfile);
  1074. #endif /* #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE) */
  1075.     }
  1076.     else
  1077.     {
  1078.         if (res_type == RES_JAVA_GAME)
  1079.         {
  1080.             printf("Populating Java Game Resourcen");
  1081.             FILE *data_file = fopen(upperFileName, "rb+");
  1082.             output_data_file = fopen(JAVA_GAME_FILENAME, "ab+");
  1083.             if (data_file == NULL)
  1084.             {
  1085.             }
  1086.             else
  1087.             {
  1088.                 U8 ch = 0, count = 0;
  1089.                 S32 data;
  1090.                 printf("Open data file successfullyn");
  1091.                 Extract_Name(output_image_names, upperFileName, RES_JAVA_GAME);
  1092.                 fprintf(output_data_file, "const U8 ");
  1093.                 fprintf(output_data_file, output_image_names);
  1094.                 fprintf(output_data_file, "[]={nt");
  1095.                 while (!feof(data_file))
  1096.                 {
  1097.                     ch = fgetc(data_file);
  1098.                     count++;
  1099.                     fprintf(output_data_file, "0x%02X,", ch);
  1100.                     if (count == 16)
  1101.                     {
  1102.                         fprintf(output_data_file, "nt");
  1103.                         count = 0;
  1104.                     }
  1105.                 }
  1106.                 fprintf(output_data_file, "n};");
  1107.                 pImageIdMap[nImgId].nImageId = nImgId;
  1108.                 strcpy(pImageNameList[*pCurrMaxImageNum].filename, upperFileName);
  1109.                 pImageIdMap[nImgId].nImageNum = *pCurrMaxImageNum;
  1110.                 (*pCurrMaxImageNum)++;
  1111.                 (*pCurrMaxImageId)++;
  1112.                 fclose(output_data_file);
  1113.                 fclose(data_file);
  1114.             }
  1115.         }
  1116.         else if (Iload(upperFileName, &nType))
  1117.         {
  1118.             pImageIdMap[nImgId].nImageId = nImgId;
  1119.             strcpy(pImageNameList[*pCurrMaxImageNum].filename, upperFileName);
  1120.             pImageIdMap[nImgId].nImageNum = *pCurrMaxImageNum;
  1121.             (*pCurrMaxImageNum)++;
  1122.             (*pCurrMaxImageId)++;
  1123.         #ifdef __MMI_RESOURCE_ENFB_SUPPORT__//100206 ENFB support
  1124.             if ((disableENFB == 0) && (ENFBAssociatedIDFlag == MMI_TRUE))
  1125.             {
  1126.                 if (ENFBAssociatedIDAdded == MMI_TRUE)//already in other associated group
  1127.                 {
  1128.                     AddENFBAssociatedIDItem(nImgId, upperFileName, res_type);
  1129.                     ENFBAssociatedIDAdded = MMI_FALSE;
  1130.                 }
  1131.             }
  1132.         #endif
  1133. #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE)
  1134.             g_resimg_table[g_resimg_count].size = g_ressize;
  1135.             strcpy(g_resimg_table[g_resimg_count].filename, filename);
  1136.             g_resimg_count ++;
  1137.             RESPRTONERECORD(fpImageResourceUsage, nImgId, filename, enum_value, resfile);
  1138. #endif /* #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE) */
  1139.         }
  1140.         /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  1141.         else    /* 040805 CustPack: Calvin modified else case to let new set of images share the same resource of default image */
  1142.         {
  1143.             if (toolFlag)
  1144.             {
  1145.                 resultFailFlag = 1;
  1146.             }
  1147.             ImageIdMap[nImgId].nImageId = nImgId;
  1148.             strcpy(ImageNameList[CurrMaxImageNum].filename, DEFAULT_FILEBUFFER);
  1149.             ImageIdMap[nImgId].nImageNum = CurrMaxImageNum;
  1150.             CurrMaxImageNum++;
  1151.             CurrMaxImageId++;
  1152.         }
  1153.         /* __CUSTPACK_MULTIBIN Calvin END */
  1154.     }
  1155.     sInfo.pDisplayValue = pDisplayName;
  1156.     sInfo.pValue = upperFileName;
  1157. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1158.     disableENFB = 0;//100206 ENFB support
  1159. #endif
  1160. }
  1161. /* 101205 audio resource Calvin Satrt */
  1162. /*****************************************************************************
  1163.  * FUNCTION
  1164.  *  SetAudioWithBuffer
  1165.  * DESCRIPTION
  1166.  *  Function to copy the audio file to buffer
  1167.  * PARAMETERS
  1168.  *  nAdoId              [IN]        
  1169.  *  filename            [?]         
  1170.  *  pDisplayName        [?]         
  1171.  *  enum_value          [?]         
  1172.  *  res_type            [IN]        
  1173.  *  adoFlag             [IN]        
  1174.  *  S8(?)               [OUT]       -> filename of the audio to be generated.
  1175.  *  U16(?)              [IN]        -> AudioId
  1176.  * RETURNS
  1177.  *  void
  1178.  *****************************************************************************/
  1179. void SetAudioWithBuffer(U16 nAdoId, S8 *filename, S8 *pDisplayName, S8 *enum_value, U32 res_type, BOOL adoFlag, S8 *resfile)      /* 120304 Calvin modified for media resource */
  1180. {
  1181.     /*----------------------------------------------------------------*/
  1182.     /* Local Variables                                                */
  1183.     /*----------------------------------------------------------------*/
  1184.     U16 i;
  1185.     U16 found = 0;
  1186.     S16 nStrlen;
  1187.     U16 nType;
  1188.     S8 upperFileName[MAX_FILENAME_LEN];
  1189.     unsigned short *pCurrMaxAudioId;
  1190.     unsigned short *pCurrMaxAudioNum;
  1191.     AUDIONAME_LIST *pAudioNameList;
  1192.     CUSTOM_AUDIO_MAP *pAudioIdMap;
  1193.     /*----------------------------------------------------------------*/
  1194.     /* Code Body                                                      */
  1195.     /*----------------------------------------------------------------*/
  1196.     if (adoFlag == TRUE)
  1197.     {
  1198.         ExtAudioFlag = TRUE;
  1199.         pCurrMaxAudioId = &CurrMaxAudioIdEXT;
  1200.         pCurrMaxAudioNum = &CurrMaxAudioNumEXT;
  1201.         pAudioNameList = AudioNameListEXT;
  1202.         pAudioIdMap = AudioIdMapEXT;
  1203.     }
  1204.     else
  1205.     {
  1206.         ExtAudioFlag = FALSE;
  1207.         pCurrMaxAudioId = &CurrMaxAudioId;
  1208.         pCurrMaxAudioNum = &CurrMaxAudioNum;
  1209.         pAudioNameList = AudioNameList;
  1210.         pAudioIdMap = AudioIdMap;
  1211.     }
  1212.     if (*pCurrMaxAudioId >= MAX_AUDIO_IDS_SIZE)
  1213.     {
  1214.         return; /* Can't add more than max number of audio ids allowed */
  1215.     }
  1216.     fprintf(OutputAdoIDFile, "file name%d = %s n", audio_idx++, filename);
  1217.     if (strlen(filename) >= MAX_FILENAME_LEN)
  1218.     {
  1219.         filename[MAX_FILENAME_LEN - 1] = '';
  1220.     }
  1221.     if (!(strcmp(filename, "")))
  1222.     {
  1223.         strcpy(filename_buffer, NOAUDIO_FILENAMEBUFFER);
  1224.     }
  1225.     nStrlen = strlen(filename);
  1226.     while (nStrlen >= 0)
  1227.     {
  1228.         upperFileName[nStrlen] = toupper(filename[nStrlen]);
  1229.         --nStrlen;
  1230.     }
  1231.     for (i = 0; i < *pCurrMaxAudioNum; i++)
  1232.     {
  1233.         if (!strcmp(pAudioNameList[i].filename, upperFileName))
  1234.         {
  1235.             found = 1;
  1236.             break;
  1237.         }
  1238.     }
  1239.     if (pAudioIdMap[nAdoId].nAudioId != 0)
  1240.     {
  1241.         switch (res_type)
  1242.         {
  1243.             case RES_AUDIO:
  1244.                 fprintf(RepeatIDListFile, "%dt%stt%sn", nAdoId, enum_value, "Audio");
  1245.                 break;
  1246.             default:
  1247.                 printf("Non supported resource type!n");
  1248.         }
  1249.     }
  1250.     g_ressize = 0;
  1251.     if (found)
  1252.     {
  1253.         pAudioIdMap[nAdoId].nAudioId = nAdoId;
  1254.         pAudioIdMap[nAdoId].nAudioNum = i;
  1255.         (*pCurrMaxAudioId)++;
  1256. #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE)
  1257.         {
  1258.             S8 str1[MAX_AUDIO_NAMES_SIZE];
  1259.             S8 str2[MAX_AUDIO_NAMES_SIZE];
  1260.             U32 i, j;
  1261.             strcpy(str1, filename);
  1262.             for (j = 0; j < strlen(str1); j++)
  1263.             {
  1264.                 str1[j] = toupper(str1[j]);
  1265.             }
  1266.             for (i = 0; i < g_resado_count; i++)
  1267.             {
  1268.                 strcpy(str2, g_resado_table[i].filename);
  1269.                 for (j = 0; j < strlen(str1); j++)
  1270.                 {
  1271.                     str2[j] = toupper(str2[j]);
  1272.                 }
  1273.                 if (strcmp(str1, str2) == 0)
  1274.                 {
  1275.                     g_ressize = g_resado_table[i].size;
  1276.                     break;
  1277.                 }
  1278.             }
  1279.         }
  1280.         RESPRTONERECORD(fpAudioResourceUsage, nAdoId, filename, enum_value, resfile);
  1281. #endif /* #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE) */
  1282.     }
  1283.     else
  1284.     {
  1285.         if (Aload(upperFileName, &nType))
  1286.         {
  1287.             pAudioIdMap[nAdoId].nAudioId = nAdoId;
  1288.             strcpy(pAudioNameList[*pCurrMaxAudioNum].filename, upperFileName);
  1289.             pAudioIdMap[nAdoId].nAudioNum = *pCurrMaxAudioNum;
  1290.             (*pCurrMaxAudioNum)++;
  1291.             (*pCurrMaxAudioId)++;
  1292. #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE)
  1293.             g_resado_table[g_resado_count].size = g_ressize;
  1294.             strcpy(g_resado_table[g_resado_count].filename, filename);
  1295.             g_resado_count ++;
  1296.             RESPRTONERECORD(fpAudioResourceUsage, nAdoId, filename, enum_value, resfile);
  1297. #endif /* #if defined(_POPULATE_RES_C) && !defined(PRODUCTION_RELEASE) */
  1298.         }
  1299.         else
  1300.         {
  1301.             if (toolFlag)
  1302.             {
  1303.                 resultFailFlag = 1;
  1304.             }
  1305.             AudioIdMap[nAdoId].nAudioId = nAdoId;
  1306.             strcpy(AudioNameList[CurrMaxAudioNum].filename, AUDIO_DEFAULT_FILEBUFFER);
  1307.             AudioIdMap[nAdoId].nAudioNum = CurrMaxAudioNum;
  1308.             CurrMaxAudioNum++;
  1309.             CurrMaxAudioId++;
  1310.         }
  1311.     }
  1312. }
  1313. /* 101205 audio resource Calvin End */
  1314. /*****************************************************************************
  1315.  * FUNCTION
  1316.  *  MenuItemPresent
  1317.  * DESCRIPTION
  1318.  *  Function to find ImageId
  1319.  * PARAMETERS
  1320.  *  ItemId      [IN]        
  1321.  *  U16(?)      [IN]        -> ImageId
  1322.  * RETURNS
  1323.  *  U16
  1324.  *****************************************************************************/
  1325. U16 MenuItemPresent(U16 ItemId)
  1326. {
  1327.     /*----------------------------------------------------------------*/
  1328.     /* Local Variables                                                */
  1329.     /*----------------------------------------------------------------*/
  1330.     U16 i;
  1331.     /*----------------------------------------------------------------*/
  1332.     /* Code Body                                                      */
  1333.     /*----------------------------------------------------------------*/
  1334.     for (i = 0; i < CurrMaxMenuItemIndex; i++)
  1335.     {
  1336.         if (nCustMenus[i].nMenuItemId == ItemId)
  1337.         {
  1338.             return TRUE;
  1339.         }
  1340.     }
  1341.     return FALSE;
  1342. }
  1343. /*****************************************************************************
  1344.  * FUNCTION
  1345.  *  PrintMenuItems
  1346.  * DESCRIPTION
  1347.  *  Fills the CUSTOM_MENU structure, for MenuTree Tool usage
  1348.  * PARAMETERS
  1349.  *  arg1        [?]         
  1350.  *  U16(?)      [IN]        -> variable argument list
  1351.  * RETURNS
  1352.  *  void
  1353.  *****************************************************************************/
  1354. static char is_dummy_code = 0;  /* To check if it needs to generate for menu tree tool or not. */
  1355. void PrintMenuItems(char *arg1)
  1356. {
  1357.     /*----------------------------------------------------------------*/
  1358.     /* Local Variables                                                */
  1359.     /*----------------------------------------------------------------*/
  1360.     /* static U8 is_first=1; */
  1361.     FILE *fout;
  1362.     /*----------------------------------------------------------------*/
  1363.     /* Code Body                                                      */
  1364.     /*----------------------------------------------------------------*/
  1365.     if (is_dummy_code == 1)
  1366.     {
  1367.         return;
  1368.     }
  1369.     if (is_first)
  1370.     {
  1371.         fout = fopen(OUTPUT_MENUTREE_FILENAME, "w");
  1372.         is_first = 0;
  1373.     }
  1374.     else
  1375.     {
  1376.         fout = fopen(OUTPUT_MENUTREE_FILENAME, "a");
  1377.     }
  1378.     fprintf(fout, "ADD_APPLICATION_MENUITEM2(%s);n", arg1);
  1379.     fclose(fout);
  1380. }
  1381. /*****************************************************************************
  1382.  * FUNCTION
  1383.  *  PrintMenuItems2
  1384.  * DESCRIPTION
  1385.  *  Fills the CUSTOM_MENU structure, for MenuTree Tool usage
  1386.  * PARAMETERS
  1387.  *  arg1        [?]         
  1388.  *  U16(?)      [IN]        -> variable argument list
  1389.  * RETURNS
  1390.  *  void
  1391.  *****************************************************************************/
  1392. void PrintMenuItems2(char *arg1, ...)
  1393. {
  1394.     /*----------------------------------------------------------------*/
  1395.     /* Local Variables                                                */
  1396.     /*----------------------------------------------------------------*/
  1397.     /* static U8 is_first=1; */
  1398.     FILE *fout;
  1399.     /*----------------------------------------------------------------*/
  1400.     /* Code Body                                                      */
  1401.     /*----------------------------------------------------------------*/
  1402.     if (is_dummy_code == 1)
  1403.     {
  1404.         return;
  1405.     }
  1406.     if (is_first)
  1407.     {
  1408.         fout = fopen(OUTPUT_MENUTREE_FILENAME, "w");
  1409.         is_first = 0;
  1410.     }
  1411.     else
  1412.     {
  1413.         fout = fopen(OUTPUT_MENUTREE_FILENAME, "a");
  1414.     }
  1415.     fprintf(fout, "ADD_APPLICATION_MENUITEM3(%s);n", arg1);
  1416.     fclose(fout);
  1417. }
  1418. /*****************************************************************************
  1419.  * FUNCTION
  1420.  *  SetMenuItem
  1421.  * DESCRIPTION
  1422.  *  Fills the CUSTOM_MENU structure
  1423.  * PARAMETERS
  1424.  *  arg1        [IN]        
  1425.  *  U16(?)      [IN]        -> variable argument list
  1426.  * RETURNS
  1427.  *  void
  1428.  *****************************************************************************/
  1429. void SetMenuItem(U16 arg1, ...)
  1430. {
  1431.     /*----------------------------------------------------------------*/
  1432.     /* Local Variables                                                */
  1433.     /*----------------------------------------------------------------*/
  1434.     U16 MemberCounter = 9;
  1435.     U16 i = arg1;
  1436.     U16 j;
  1437.     U16 menuItemID;
  1438.     va_list argumentPtr;
  1439.     /*----------------------------------------------------------------*/
  1440.     /* Code Body                                                      */
  1441.     /*----------------------------------------------------------------*/
  1442.     /* 091004 MTK Calvin removed to reduce populate time */
  1443.     //FILE  *fout;
  1444.     //static U8 is_first=1;
  1445.     //if (is_first)
  1446.     //{
  1447.     //   fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"w");
  1448.     //   is_first= 0;
  1449.     //}
  1450.     /* MTK Calvin end */
  1451. #ifdef _POPULATE_RES_C
  1452.     va_start(argumentPtr, arg1);
  1453. #endif /* _POPULATE_RES_C */
  1454.     RESPRT(fpMenuResourceUsage, "NO_APP", -1, i, "unknown", 1, "none", g_resmenu_filename);
  1455.     /* Need to decide whether menu item already present */
  1456.     if (!MenuItemPresent(i))
  1457.     {
  1458.         /* 091004 MTK Calvin removed fopen and fclose to reduce populate time and replaced fout with OutputMenutreeIDFile */
  1459.         /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1460.         fprintf(OutputMenutreeIDFile, "ADD_APPLICATION_MENUITEM2((", arg1);
  1461.         /* fclose(fout); */
  1462.         is_dummy_code = 0;
  1463.         while (MemberCounter)
  1464.         {
  1465.             switch (MemberCounter)
  1466.             {
  1467.                 case MENUITEM_ID_TYPE:
  1468.                     menuItemID = i - 1;
  1469.                     nCustMenus[menuItemID].nMenuItemId = i;
  1470.                     /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1471.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1472.                     /* fclose(fout); */
  1473.                     break;
  1474.                 case PARENT_ITEM_ID_TYPE:
  1475.                     nCustMenus[menuItemID].nParentId = i;
  1476.                     /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1477.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1478.                     /* fclose(fout); */
  1479.                     break;
  1480.                 case NUMBER_OF_MENUITEMS_TYPE:
  1481.                     nCustMenus[menuItemID].nNumofMenuItem = i;
  1482.                     /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1483.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1484.                     /* fclose(fout); */
  1485.                     break;
  1486.                 case MENU_ITEM_ORDER_TYPE:
  1487.                     if (nCustMenus[menuItemID].nNumofMenuItem == 0)
  1488.                     {
  1489.                         nCustMenus[menuItemID].nOrderMenuItemId = (U16*) 0;
  1490.                     }
  1491.                     else
  1492.                     {
  1493.                         nCustMenus[menuItemID].nOrderMenuItemId = (U16*) malloc(sizeof(U16) * MENU_ITEM_SIZE);
  1494.                         for (j = 0; j < nCustMenus[menuItemID].nNumofMenuItem; j++)
  1495.                         {
  1496.                             /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1497.                             fprintf(OutputMenutreeIDFile, "%d,", i);
  1498.                             /* fclose(fout); */
  1499.                             nCustMenus[menuItemID].nOrderMenuItemId[j] = i;
  1500.                             i = va_arg(argumentPtr, int);
  1501.                         }
  1502.                     }
  1503.                     break;
  1504.                 case HIDE_FLAG_TYPE:
  1505.                     nCustMenus[menuItemID].nHideFlag = i;
  1506.                     /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1507.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1508.                     /* fclose(fout); */
  1509.                     break;
  1510.                 case MOVEABLE_FLAG_TYPE:
  1511.                     nCustMenus[menuItemID].nMovable = i;
  1512.                     /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1513.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1514.                     /* fclose(fout); */
  1515.                     break;
  1516.                 case DISPLAY_ATTRIBUTE_TYPE:
  1517.                     nCustMenus[menuItemID].nDispAttribute = i;
  1518.                     /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1519.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1520.                     /* fclose(fout); */
  1521.                     break;
  1522.                 case MENU_ITEM_STRING_ID_TYPE:
  1523.                     nCustMenus[menuItemID].nStrId = i;
  1524.                     /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1525.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1526.                     /* fclose(fout); */
  1527.                     break;
  1528.                 case MENU_ITEM_IMAGE_ID_TYPE:
  1529.                     nCustMenus[menuItemID].nImageId = i;
  1530.                     /* fout = fopen(OUTPUT_MENUTREE_ID_FILENAME,"a"); */
  1531.                     fprintf(OutputMenutreeIDFile, "%d));n", i);
  1532.                     /* fclose(fout); */
  1533.                     break;
  1534.             }
  1535.             if (MemberCounter != MENU_ITEM_ORDER_TYPE)
  1536.             {
  1537.                 i = va_arg(argumentPtr, int);
  1538.             }
  1539.             MemberCounter--;
  1540.         }
  1541.         /* MTK Calvin end */
  1542.     }
  1543.     else
  1544.     {
  1545.         is_dummy_code = 1;
  1546.     }
  1547.     va_end(argumentPtr);
  1548. }
  1549. /*****************************************************************************
  1550.  * FUNCTION
  1551.  *  SetMenuItem2
  1552.  * DESCRIPTION
  1553.  *  Fills the CUSTOM_MENU structure
  1554.  * PARAMETERS
  1555.  *  arg1        [IN]        
  1556.  *  U16(?)      [IN]        -> variable argument list
  1557.  * RETURNS
  1558.  *  void
  1559.  *****************************************************************************/
  1560. void SetMenuItem2(U16 arg1, ...)
  1561. {
  1562.     /*----------------------------------------------------------------*/
  1563.     /* Local Variables                                                */
  1564.     /*----------------------------------------------------------------*/
  1565.     U16 MemberCounter = 9;
  1566.     U16 i = arg1;
  1567.     U16 j;
  1568.     U16 menuItemID;
  1569.     va_list argumentPtr;
  1570.     /*----------------------------------------------------------------*/
  1571.     /* Code Body                                                      */
  1572.     /*----------------------------------------------------------------*/
  1573.     va_start(argumentPtr, arg1);
  1574. #ifdef _POPULATE_RES_C
  1575.     RESPRT(fpMenuResourceUsage, "NO_APP", -1, i, "unknown", 1, "none", g_resmenu_filename);
  1576. #endif /* _POPULATE_RES_C */
  1577.     /* Need to decide whether menu item already present */
  1578.     if (!MenuItemPresent(i))
  1579.     {
  1580.         fprintf(OutputMenutreeIDFile, "ADD_APPLICATION_MENUITEM2((", arg1);
  1581.         is_dummy_code = 0;
  1582.         while (MemberCounter)
  1583.         {
  1584.             switch (MemberCounter)
  1585.             {
  1586.                 case MENUITEM_ID_TYPE:
  1587.                     menuItemID = i - 1;
  1588.                     nCustMenus[menuItemID].nMenuItemId = i;
  1589.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1590.                     break;
  1591.                 case PARENT_ITEM_ID_TYPE:
  1592.                     nCustMenus[menuItemID].nParentId = i;
  1593.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1594.                     break;
  1595.                 case MENU_ITEM_ORDER_TYPE:
  1596.                     if ( /* nCustMenus[menuItemID].nNumofMenuItem==0 || */ i == MENU_ITEM_END)
  1597.                     {
  1598.                         nCustMenus[menuItemID].nOrderMenuItemId = (U16*) 0;
  1599.                         fprintf(OutputMenutreeIDFile, "0,");
  1600.                         i = va_arg(argumentPtr, int);
  1601.                     }
  1602.                     else
  1603.                     {
  1604.                         U16 number_of_child = 0;
  1605.                         nCustMenus[menuItemID].nOrderMenuItemId = (U16*) malloc(sizeof(U16) * MENU_ITEM_SIZE);
  1606.                         while (i < MENU_ITEM_END)
  1607.                         {
  1608.                             nCustMenus[menuItemID].nOrderMenuItemId[number_of_child] = i;
  1609.                             i = va_arg(argumentPtr, int);
  1610.                             number_of_child++;
  1611.                         }
  1612.                         nCustMenus[menuItemID].nNumofMenuItem = number_of_child;        /* Set number of child field */
  1613.                         fprintf(OutputMenutreeIDFile, "%d,", number_of_child);
  1614.                         for (i = 0; i < number_of_child; i++)
  1615.                         {
  1616.                             fprintf(OutputMenutreeIDFile, "%d,", nCustMenus[menuItemID].nOrderMenuItemId[i]);
  1617.                         }
  1618.                         i = va_arg(argumentPtr, int);   /* read in next argument. */
  1619.                     }
  1620.                     break;
  1621.                 case HIDE_FLAG_TYPE:
  1622.                     nCustMenus[menuItemID].nHideFlag = i;
  1623.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1624.                     break;
  1625.                 case MOVEABLE_FLAG_TYPE:
  1626.                     nCustMenus[menuItemID].nMovable = i;
  1627.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1628.                     break;
  1629.                 case DISPLAY_ATTRIBUTE_TYPE:
  1630.                     nCustMenus[menuItemID].nDispAttribute = i;
  1631.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1632.                     break;
  1633.                 case MENU_ITEM_STRING_ID_TYPE:
  1634.                     nCustMenus[menuItemID].nStrId = i;
  1635.                     fprintf(OutputMenutreeIDFile, "%d,", i);
  1636.                     break;
  1637.                 case MENU_ITEM_IMAGE_ID_TYPE:
  1638.                     nCustMenus[menuItemID].nImageId = i;
  1639.                     fprintf(OutputMenutreeIDFile, "%d));n", i);
  1640.                     break;
  1641.             }
  1642.             if (MemberCounter != MENU_ITEM_ORDER_TYPE)
  1643.             {
  1644.                 i = va_arg(argumentPtr, int);
  1645.             }
  1646.             if (MemberCounter == PARENT_ITEM_ID_TYPE)   /* Skip NUMBER_OF_MENUITEMS_TYPE field */
  1647.             {
  1648.                 MemberCounter -= 2;
  1649.             }
  1650.             else
  1651.             {
  1652.                 MemberCounter--;
  1653.             }
  1654.         }
  1655.     }
  1656.     else
  1657.     {
  1658.         is_dummy_code = 1;
  1659.     }
  1660.     va_end(argumentPtr);
  1661. }
  1662. /*****************************************************************************
  1663.  * FUNCTION
  1664.  *  Get_Image_Identifier
  1665.  * DESCRIPTION
  1666.  *  Identifies the image , BMP , ppf etc
  1667.  *  
  1668.  *  This function will be refined later when multiple
  1669.  *  image type will be supported by the frame work
  1670.  *  rt. now it just a added hook to make the design complete
  1671.  * PARAMETERS
  1672.  *  extension_type      [IN]        
  1673.  * RETURNS
  1674.  *  U8
  1675.  *****************************************************************************/
  1676. U8 Get_Image_Identifier(S32 extension_type)
  1677. {
  1678.     /*----------------------------------------------------------------*/
  1679.     /* Local Variables                                                */
  1680.     /*----------------------------------------------------------------*/
  1681.     S32 ret;
  1682.     /*----------------------------------------------------------------*/
  1683.     /* Code Body                                                      */
  1684.     /*----------------------------------------------------------------*/
  1685.     if (extension_type < 0)
  1686.     {
  1687.         ret = 0;
  1688.     }
  1689.     else if (extension_type == 0)
  1690.     {
  1691.         ret = 1;
  1692.     }
  1693.     return (U8) ret;
  1694. }
  1695. /*****************************************************************************
  1696.  * FUNCTION
  1697.  *  Load_Image_Data
  1698.  * DESCRIPTION
  1699.  *  Identifies the image , BMP , ppf etc
  1700.  * PARAMETERS
  1701.  *  offset                  [OUT]       File offset --> file offset
  1702.  *  output_file             [IN]        -> Name of the file to which buffer
  1703.  *  input_file              [IN]        ->  Name of the input image file
  1704.  *  pImgData                [OUT]       -> buffer containing image data
  1705.  *  image_identifier        [IN]        -> image identifier
  1706.  *  n_frames                [IN]        -> no of frames
  1707.  *  is(?)                   [IN]        To be written
  1708.  * RETURNS
  1709.  *  S32 --> file size
  1710.  *****************************************************************************/
  1711. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  1712. /* 040805 CustPack: Calvin modified */
  1713. S32 Load_Image_Data(
  1714.         U32 *offset,
  1715.         FILE *output_file,
  1716.         FILE *input_file,
  1717.         U8 *pImgData,
  1718.         U8 image_identifier,
  1719.         S32 n_frames)
  1720. {
  1721.     /*----------------------------------------------------------------*/
  1722.     /* Local Variables                                                */
  1723.     /*----------------------------------------------------------------*/
  1724.     U32 file_size, i, o = 0;
  1725.     U8 ch;
  1726.     /*----------------------------------------------------------------*/
  1727.     /* Code Body                                                      */
  1728.     /*----------------------------------------------------------------*/
  1729.     fseek(input_file, 0, SEEK_END);
  1730.     file_size = ftell(input_file);
  1731.     fseek(input_file, 0, SEEK_SET);
  1732.     if (toolFlag)
  1733.     {
  1734.         fprintf(dest_file, "%c%c", image_identifier, n_frames);
  1735.         if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
  1736.             image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
  1737.             image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
  1738.             image_identifier == IMAGE_TYPE_SWFLASH)
  1739.         {
  1740.             fprintf(
  1741.                 dest_file,
  1742.                 "%c%c%c%c%c%c",
  1743.                 file_size & 0xff,
  1744.                 (file_size & 0xff00) >> 8,
  1745.                 (file_size & 0xff0000) >> 16,
  1746.                 (file_size & 0xff000000) >> 24,
  1747.                 0,
  1748.                 0);
  1749.         }
  1750.         else
  1751.         {
  1752.             fprintf(
  1753.                 dest_file,
  1754.                 "%c%c%c%c",
  1755.                 file_size & 0xff,
  1756.                 (file_size & 0xff00) >> 8,
  1757.                 (file_size & 0xff0000) >> 16,
  1758.                 (file_size & 0xff000000) >> 24);
  1759.         }
  1760.     }
  1761.     /* 100206 ENFB support Start */
  1762. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1763.     else if (enfbFlag == 1) /* write ENFB header to CustImgDataxxx.h and image header/data to ENFB image data file */
  1764.     {
  1765.         fprintf(enfb_img_data_file, "%c%c", image_identifier, n_frames);
  1766.         if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
  1767.             image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
  1768.             image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
  1769.             image_identifier == IMAGE_TYPE_SWFLASH)
  1770.         {
  1771.             fprintf(
  1772.                 enfb_img_data_file,
  1773.                 "%c%c%c%c%c%c",
  1774.                 file_size & 0xff,
  1775.                 (file_size & 0xff00) >> 8,
  1776.                 (file_size & 0xff0000) >> 16,
  1777.                 (file_size & 0xff000000) >> 24,
  1778.                 0,
  1779.                 0);
  1780.             enfb_size = 8 + file_size;
  1781.         }
  1782.         else
  1783.         {
  1784.             fprintf(
  1785.                 enfb_img_data_file,
  1786.                 "%c%c%c%c",
  1787.                 file_size & 0xff,
  1788.                 (file_size & 0xff00) >> 8,
  1789.                 (file_size & 0xff0000) >> 16,
  1790.                 (file_size & 0xff000000) >> 24);
  1791.             enfb_size = 6 + file_size;
  1792.         }
  1793.         
  1794.         /* write ENFB header to CustImgDataxxx.h */
  1795.         fprintf(
  1796.             output_file,
  1797.             "nt0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02Xt",
  1798.             (U8) 255,//type
  1799.             (U8) ENFBAssociatedIDAdded,//associated id
  1800.             (U8) 0,//reserved
  1801.             (U8) 0,//reserved
  1802.             (U8) (enfb_offset & 0xff),
  1803.             (U8) ((enfb_offset >> 8) & 0xff),
  1804.             (U8) ((enfb_offset >> 16) & 0xff),
  1805.             (U8) ((enfb_offset >> 24) & 0xff),
  1806.             (U8) (enfb_size & 0xff),
  1807.             (U8) ((enfb_size >> 8) & 0xff),
  1808.             (U8) ((enfb_size >> 16) & 0xff),
  1809.             (U8) ((enfb_size >> 24) & 0xff));
  1810.         
  1811.         enfb_offset += enfb_size;
  1812.     }
  1813. #endif
  1814. /* 100206 ENFB support End */   
  1815.     else
  1816.     {
  1817.         fprintf(output_data_file, "nt0x%02X, 0x%02X, ", image_identifier, n_frames);
  1818.         if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
  1819.             image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
  1820.             image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
  1821.             image_identifier == IMAGE_TYPE_SWFLASH)
  1822.         {
  1823.             fprintf(
  1824.                 output_file,
  1825.                 "0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x00, 0x00,nt",
  1826.                 file_size & 0xff,
  1827.                 (file_size & 0xff00) >> 8,
  1828.                 (file_size & 0xff0000) >> 16,
  1829.                 (file_size & 0xff000000) >> 24);
  1830.         }
  1831.         else
  1832.         {
  1833.             fprintf(
  1834.                 output_file,
  1835.                 "0x%02X, 0x%02X, 0x%02X, 0x%02X,nt",
  1836.                 file_size & 0xff,
  1837.                 (file_size & 0xff00) >> 8,
  1838.                 (file_size & 0xff0000) >> 16,
  1839.                 (file_size & 0xff000000) >> 24);
  1840.         }
  1841.     }
  1842.     pImgData[0] = (U8) image_identifier;
  1843.     pImgData[1] = (U8) n_frames;
  1844.     pImgData[2] = (U8) (file_size & 0xff);
  1845.     pImgData[3] = (U8) ((file_size & 0xff00) >> 8);
  1846.     pImgData[4] = (U8) ((file_size & 0xff0000) >> 16);
  1847.     pImgData[5] = (U8) ((file_size & 0xff000000) >> 24);
  1848.     for (i = 0; i < file_size; i++)
  1849.     {
  1850.         ch = fgetc(input_file);
  1851.         if (toolFlag)
  1852.         {
  1853.             fputc(ch, dest_file);
  1854.             (*offset)++;
  1855.             (pImgData)[i + 6] = ch;
  1856.         }
  1857.     /* 100206 ENFB support Start */
  1858.     #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1859.         else if (enfbFlag == 1) /* write image data to ENFB image data file */
  1860.         {
  1861.             fputc(ch, enfb_img_data_file);
  1862.             (*offset)++;
  1863.             (pImgData)[i + 6] = ch;
  1864.         }
  1865.     #endif
  1866.     /* 100206 ENFB support End */   
  1867.         else
  1868.         {
  1869.             fprintf(output_file, "0x%02X, ", ch);
  1870.             (*offset)++;
  1871.             (pImgData)[i + 6] = ch;
  1872.             o++;
  1873.             if ((o % 16) == 0)
  1874.             {
  1875.                 fprintf(output_file, "nt");
  1876.             }
  1877.         }
  1878.     }
  1879.     if (image_identifier == IMAGE_TYPE_GIF || image_identifier == IMAGE_TYPE_3GP ||
  1880.         image_identifier == IMAGE_TYPE_MP4 || image_identifier == IMAGE_TYPE_AVI ||
  1881.         image_identifier == IMAGE_TYPE_PNG || image_identifier == IMAGE_TYPE_M3D ||
  1882.         image_identifier == IMAGE_TYPE_SWFLASH)
  1883.     {
  1884.         return file_size + 8;
  1885.     }
  1886.     else
  1887.     {
  1888.         return file_size + 6;
  1889.     }
  1890. }
  1891. /* 101205 audio resource Calvin Satrt */
  1892. /*****************************************************************************
  1893.  * FUNCTION