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

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.  * MyPicture.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  * PDG-1
  44.  *
  45.  * Description:
  46.  * ------------
  47.  * This file implements procedures to save and retreive ringtones.
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  *------------------------------------------------------------------------------
  72.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  73.  *============================================================================
  74.  ****************************************************************************/
  75.  /**
  76.  * Copyright Notice
  77.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  78.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  79.  *  (It is illegal to remove this copyright notice from this software or any
  80.  *  portion of it)
  81.  */
  82. /**************************************************************
  83.    FILENAME : MyPicture.c
  84.    PURPOSE     : Main function to save and retreive pictures
  85.    REMARKS     : nil
  86.    AUTHOR      : JaiPrakash S.
  87.    DATE     : Oct-11-2004
  88. **************************************************************/
  89. #include "MMI_Features.h"
  90. #ifdef __MOD_SMSAL__
  91. /*  Include: MMI header file */
  92. #include "stdC.h"
  93. #include "L4Dr1.h"
  94. #include "PixtelDataTypes.h"
  95. /* ... Add More MMI header */
  96. #include "EventsGprot.h"
  97. #include "HistoryGprot.h"
  98. #include "GlobalMenuItems.h"
  99. #include "GlobalConstants.h"
  100. #include "Globaldefs.h"
  101. #include "wgui_categories.h"
  102. #include "wgui_categories_inputs.h"
  103. #include "CustMenuRes.h"
  104. #include "CommonScreens.h"
  105. #include "Unicodexdcl.h"
  106. #include "TimerEvents.h"
  107. #include "DebugInitDef.h"
  108. /* ...Add MSG header */
  109. #include "customer_ps_inc.h"
  110. #include "MessagesL4Def.h"
  111. #include "MessagesResourceData.h"
  112. #include "MessagesMiscell.h"
  113. #include "MessagesExDcl.h"
  114. #include "SmsGuiInterfaceProt.h"
  115. #include "SmsGuiInterfaceType.h"
  116. #include "SmsPsHandler.h"
  117. #include "mmi_msg_context.h"
  118. #include "CellBroadcastType.h"
  119. #ifdef __MMI_MESSAGES_CHAT__
  120. #include "ChatAppGprot.h"
  121. #include "ChatAppDef.h"
  122. #include "ChatGtype.h"
  123. #include "ChatAppGexdcl.h"
  124. #endif /* __MMI_MESSAGES_CHAT__ */ 
  125. #include "DownloadProtos.h"
  126. #include "DownloadDefs.h"
  127. #include "Gui_ems.h"
  128. #include "wgui_ems.h"
  129. #include "GSM7BitDefaultAlphabet.h"
  130. #include "ProtocolEvents.h"
  131. #include "SettingDefs.h"
  132. #include "SettingsGdcl.h"
  133. /*  */
  134. #include "smsal_l4c_enum.h"
  135. /*  */
  136. #include "NVRAMEnum.h"
  137. #include "NVRAMProt.h"
  138. #include "NVRAMType.h"
  139. /*  */
  140. #include "CSP.h"
  141. #include "FrameworkStruct.h"
  142. #include "MainMenuDef.h"
  143. #include "CallHistoryGProts.h"
  144. #include "CallManagementGprot.h"
  145. #include "CallhistoryEnum.h"
  146. #include "MiscFunctions.h"
  147. #include "SettingProfile.h"
  148. #include "ProfileGprots.h"
  149. #include "PhoneBookGprot.h"
  150. #include "IdleAppProt.h"
  151. #include "AlarmFrameworkProt.h"
  152. #include "CallsDefs.h"
  153. #include "wgui_status_icons.h"
  154. #include "gpioInc.h"
  155. #include "KeyBrd.h"
  156. #include "SubLCDHistoryGprot.h"
  157. #include "mdi_datatype.h"
  158. #include "mdi_audio.h"
  159. #include "PicMsgApiToOthers.h"
  160. #include "FileSystemDef.h"
  161. #include "MyPicture.h"
  162. #include "MyTone.h"
  163. #ifdef __MMI_EMAIL__
  164. #include "EmailAppGProt.h"
  165. #endif 
  166. #include "FileMgr.h"
  167. #include "FileManagerDef.h"
  168. #if defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  169. extern S32 mmi_nsm_send_pic_msg(U8 *bmpDataPtr, U8 *PicTextPtr);
  170. extern U32 mmi_smrt_midi_file_size(U8 *midifile);
  171. S8 PictureMessageDir[NSM_FILE_NAME_BUFF];
  172. U8 gNSMBuffer[1024];    /* Global buffer for NSM picture and ringtone message */
  173. U8 gaddtext_buffer[MAX_PICMSG_DEFAULT_DCS_TEXT_LEN];
  174. #endif /* defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  175. #if defined(__MMI_MYPICTURE__)
  176. U8 gaddtext_buffer[320];
  177. U8 gfilecount = 0;
  178. void display_nsm_mypicture_list(void);
  179. extern U16 gSelected_Item;
  180. extern U8 gfilecount;
  181. extern PendingSaveSendDataStruct PendingSaveSendData;
  182. /*****************************************************************************
  183.  * FUNCTION
  184.  *  highlight_mypic_handler
  185.  * DESCRIPTION
  186.  *  Highlight handler for My Picture
  187.  * PARAMETERS
  188.  *  void
  189.  * RETURNS
  190.  *  void
  191.  *****************************************************************************/
  192. void highlight_mypic_handler(void)
  193. {
  194. #ifdef MMI_ON_WIN32
  195.     /*----------------------------------------------------------------*/
  196.     /* Local Variables                                                */
  197.     /*----------------------------------------------------------------*/
  198.     /*----------------------------------------------------------------*/
  199.     /* Code Body                                                      */
  200.     /*----------------------------------------------------------------*/
  201.     SetLeftSoftkeyFunction(mmi_mypic_entry_options, KEY_EVENT_UP);
  202.     SetKeyHandler(mmi_mypic_entry_options, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  203.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  204.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  205. #endif /* MMI_ON_WIN32 */ 
  206. #if defined(__MMI_FILE_MANAGER__)
  207. #if defined(MMI_ON_HARDWARE_P)
  208.     SetLeftSoftkeyFunction(mmi_mypic_pre_entry_mypic_list, KEY_EVENT_UP);
  209.     SetKeyHandler(mmi_mypic_pre_entry_mypic_list, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  210.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  211.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  212. #endif /* defined(MMI_ON_HARDWARE_P) */ 
  213. #endif /* defined(__MMI_FILE_MANAGER__) */ 
  214. }
  215. /*****************************************************************************
  216.  * FUNCTION
  217.  *  mmi_mypic_pre_entry_mypic_list
  218.  * DESCRIPTION
  219.  *  Pre Entry function to display list of pictures in My Picture
  220.  * CALLS
  221.  *  mmi_nsm_get_list        To get picture list in My Picture
  222.  *  mmi_mypic_entry_mypic_list To display picture list
  223.  * PARAMETERS
  224.  *  void
  225.  * RETURNS
  226.  *  void
  227.  *****************************************************************************/
  228. void mmi_mypic_pre_entry_mypic_list(void)
  229. {
  230. #if defined(__MMI_FILE_MANAGER__)
  231.     /*----------------------------------------------------------------*/
  232.     /* Local Variables                                                */
  233.     /*----------------------------------------------------------------*/
  234. #if defined(MMI_ON_HARDWARE_P)
  235.     S8 DirPath[64];
  236.     /*----------------------------------------------------------------*/
  237.     /* Code Body                                                      */
  238.     /*----------------------------------------------------------------*/
  239.     memset(gNSMBuffer, '', 1024);
  240.     memset(gaddtext_buffer, '', 320);
  241.     memset(DirPath, '', sizeof(DirPath));
  242.     display_nsm_mypicture_list();
  243. #endif /* defined(MMI_ON_HARDWARE_P) */ 
  244. #endif /* defined(__MMI_FILE_MANAGER__) */ 
  245. }
  246. /*****************************************************************************
  247.  * FUNCTION
  248.  *  display_nsm_mypicture_list
  249.  * DESCRIPTION
  250.  *  
  251.  * PARAMETERS
  252.  *  void
  253.  * RETURNS
  254.  *  void
  255.  *****************************************************************************/
  256. void display_nsm_mypicture_list(void)
  257. {
  258.     /*----------------------------------------------------------------*/
  259.     /* Local Variables                                                */
  260.     /*----------------------------------------------------------------*/
  261.     S8 DirPath[64];
  262.     FMGR_FILTER filter;
  263.     /*----------------------------------------------------------------*/
  264.     /* Code Body                                                      */
  265.     /*----------------------------------------------------------------*/
  266.     memset(PictureMessageDir, 0x00, NSM_FILE_NAME_BUFF);
  267.     /* Get directory path for My Picture */
  268.     sprintf(DirPath, "%c:\%s", MMI_PUBLIC_DRV, (S8*) "Images\");
  269.     FMGR_FILTER_INIT(&filter);
  270.     FMGR_FILTER_SET(&filter, FMGR_TYPE_BMP);
  271.     FMGR_FILTER_SET(&filter, FMGR_TYPE_FOLDER);
  272.     FMGR_FILTER_SET(&filter, FMGR_TYPE_FOLDER_DOT);
  273.     /* pfnUnicodeStrcat((S8*)DirPath, ( S8*)FMGR_DEFAULT_FOLDER_IMAGES); */
  274.     AnsiiToUnicodeString((S8*) PictureMessageDir, (S8*) DirPath);     // DirPath/*.*
  275.     mmi_fmgr_select_path_and_enter(
  276.         APP_MESSAGES,
  277.         FMGR_SELECT_FILE,
  278.         filter,
  279.         (PS8) PictureMessageDir,
  280.         (PsExtFuncPtr) mmi_mypic_pre_entry_display_pic);
  281. }
  282. /*****************************************************************************
  283.  * FUNCTION
  284.  *  mmi_mypic_pre_entry_display_pic
  285.  * DESCRIPTION
  286.  *  Entry function to display selected pictures in My Picture
  287.  * CALLS
  288.  *  mmi_get_file_data    To get file data in global buffer gNSMBuffer
  289.  * PARAMETERS
  290.  *  filePath        [IN]        
  291.  *  is_short        [IN]        
  292.  * RETURNS
  293.  *  void
  294.  *****************************************************************************/
  295. void mmi_mypic_pre_entry_display_pic(PU16 filePath, int is_short)
  296. {
  297.     /*----------------------------------------------------------------*/
  298.     /* Local Variables                                                */
  299.     /*----------------------------------------------------------------*/
  300.     FS_HANDLE file_handle = 0;
  301.     INT wByte = 0;
  302.     S16 Result = 0;
  303.     /*----------------------------------------------------------------*/
  304.     /* Code Body                                                      */
  305.     /*----------------------------------------------------------------*/
  306.     if (filePath == NULL)
  307.     {
  308.         GoBackHistory();
  309.         return;
  310.     }
  311.     file_handle = pfopen(filePath, PFS_READ);
  312.     if (file_handle >= 0)
  313.     {
  314.         pfread((void*)gNSMBuffer, 1, 1024, file_handle, &wByte);
  315.         pfclose(file_handle);
  316.     }
  317.     Result = mmi_pmsg_add_bmp_header_info(gNSMBuffer);
  318.     if (Result != 0)
  319.     {
  320.         DisplayPopup(
  321.             (U8*) GetString(STR_ID_NSM_RINGTOEN_FORMAT_NOT_SUPPORTED_MSG),
  322.             IMG_GLOBAL_WARNING,
  323.             1,
  324.             MESSAGES_POPUP_TIME_OUT,
  325.             (U8) ERROR_TONE);
  326.         return;
  327.     }
  328.     mmi_mypic_entry_display_pic();
  329. }
  330. /*****************************************************************************
  331.  * FUNCTION
  332.  *  mmi_mypic_entry_display_pic
  333.  * DESCRIPTION
  334.  *  Display a picture message
  335.  * PARAMETERS
  336.  *  void
  337.  * RETURNS
  338.  *  void
  339.  *****************************************************************************/
  340. void mmi_mypic_entry_display_pic(void)
  341. {
  342.     /*----------------------------------------------------------------*/
  343.     /* Local Variables                                                */
  344.     /*----------------------------------------------------------------*/
  345.     U8 *guiBuffer = NULL;
  346.     /*----------------------------------------------------------------*/
  347.     /* Code Body                                                      */
  348.     /*----------------------------------------------------------------*/
  349.     EntryNewScreen(SCR_ID_MYPIC_DISPLAY, mmi_msg_exit_generic, mmi_mypic_entry_display_pic, NULL);
  350.     DeleteScreenIfPresent(SCR_FMGR_EXPLORER);
  351.     mmi_nsm_set_msg_type(PICTURE_MESSAGE);
  352.     SetMessagesCurrScrnID(SCR_ID_MYPIC_DISPLAY);
  353.     guiBuffer = GetCurrGuiBuffer(SCR_ID_MYPIC_DISPLAY);
  354.     ShowCategory620Screen(
  355.         STR_ID_NSM_PICTURE,
  356.         0,
  357.         STR_GLOBAL_OPTIONS,
  358.         0,
  359.         STR_GLOBAL_BACK,
  360.         0,
  361.         gaddtext_buffer,
  362.         NULL,
  363.         gNSMBuffer,
  364.         guiBuffer);
  365.     SetLeftSoftkeyFunction(mmi_mypic_entry_options, KEY_EVENT_UP);
  366.     SetKeyHandler(mmi_mypic_entry_options, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  367.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  368.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  369. }
  370. /*****************************************************************************
  371.  * FUNCTION
  372.  *  mmi_mypic_entry_options
  373.  * DESCRIPTION
  374.  *  Entry function to display My Picture options
  375.  * PARAMETERS
  376.  *  void
  377.  * RETURNS
  378.  *  void
  379.  *****************************************************************************/
  380. void mmi_mypic_entry_options(void)
  381. {
  382.     /*----------------------------------------------------------------*/
  383.     /* Local Variables                                                */
  384.     /*----------------------------------------------------------------*/
  385.     U8 *guiBuffer = NULL;
  386.     U16 numItems = 0;
  387.     U16 nStrItemList[MAX_SUB_MENUS];
  388.     /*----------------------------------------------------------------*/
  389.     /* Code Body                                                      */
  390.     /*----------------------------------------------------------------*/
  391. #ifdef MMI_ON_WIN32
  392.     mmi_nsm_set_msg_type(PICTURE_MESSAGE);
  393. #endif 
  394.     EntryNewScreen(SCR_ID_MYPIC_OPTION, mmi_msg_exit_generic, mmi_mypic_entry_options, NULL);
  395.     SetMessagesCurrScrnID(SCR_ID_MYPIC_OPTION);
  396.     guiBuffer = GetCurrGuiBuffer(SCR_ID_MYPIC_OPTION);
  397.     numItems = GetNumOfChild(MENU_ID_MY_PICTURE);
  398.     GetSequenceStringIds(MENU_ID_MY_PICTURE, nStrItemList);
  399.     SetParentHandler(MENU_ID_MY_PICTURE);
  400.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  401.     ShowCategory52Screen(
  402.         STR_GLOBAL_OPTIONS,
  403.         IMG_SMS_ENTRY_SCRN_CAPTION,
  404.         STR_GLOBAL_OK,
  405.         IMG_GLOBAL_OK,
  406.         STR_GLOBAL_BACK,
  407.         IMG_GLOBAL_BACK,
  408.         numItems,
  409.         nStrItemList,
  410.         (U16*) gIndexIconsImageList,
  411.         NULL,
  412.         0,
  413.         0,
  414.         guiBuffer);
  415. }
  416. #endif /* defined(__MMI_MYPICTURE__) */ 
  417. #if defined(__MMI_MYPICTURE__) || defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__))
  418. /*****************************************************************************
  419.  * FUNCTION
  420.  *  mmi_nsm_create_dir
  421.  * DESCRIPTION
  422.  *  Create a directory at the given path
  423.  * PARAMETERS
  424.  *  DirnameInAnsii      [?]         
  425.  *  DirPath(?)          [IN]        DirPath in Ansii
  426.  * RETURNS
  427.  *  void
  428.  *****************************************************************************/
  429. void mmi_nsm_create_dir(S8 *DirnameInAnsii)
  430. {
  431.     /*----------------------------------------------------------------*/
  432.     /* Local Variables                                                */
  433.     /*----------------------------------------------------------------*/
  434.     FS_HANDLE file_handle;
  435.     S8 DirnameInUnicode[96];
  436.     /*----------------------------------------------------------------*/
  437.     /* Code Body                                                      */
  438.     /*----------------------------------------------------------------*/
  439.     AnsiiToUnicodeString((S8*) DirnameInUnicode, (S8*) DirnameInAnsii);
  440.     file_handle = FS_Open((PU16) DirnameInUnicode, FS_OPEN_DIR | FS_READ_ONLY);
  441.     if (file_handle < 0)
  442.     {
  443.         pcreateDir(DirnameInUnicode);
  444.     }
  445.     pfclose(file_handle);
  446. }
  447. /*****************************************************************************
  448.  * FUNCTION
  449.  *  mmi_nsm_save_buffer_in_file
  450.  * DESCRIPTION
  451.  *  Create a file and save buffer in that file
  452.  * PARAMETERS
  453.  *  fullfilenameInUnicode       [IN]        Absolute file name in Unicode
  454.  * RETURNS
  455.  * BOOL
  456.  *****************************************************************************/
  457. U16 mmi_nsm_save_buffer_in_file(S8 *fullfilenameInUnicode)
  458. {
  459.     /*----------------------------------------------------------------*/
  460.     /* Local Variables                                                */
  461.     /*----------------------------------------------------------------*/
  462.     INT file_handle;
  463.     // S8 fullfilenameInUnicode[128];   /* JP to fix MTK Chinese file name */
  464.     U32 wByte = 0;
  465.     U16 BufferSize = 0;
  466.     S32 result;
  467.     S8 temp[NSM_DIRECTORY_BUFF];
  468.     /*----------------------------------------------------------------*/
  469.     /* Code Body                                                      */
  470.     /*----------------------------------------------------------------*/
  471.     // memset(fullfilenameInUnicode,0x00,128);  /* JP to fix MTK Chinese file name */
  472.     memset(temp, '', NSM_DIRECTORY_BUFF);
  473.     if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  474.     {
  475.         sprintf(temp, "%c:\%s", MMI_PUBLIC_DRV, (S8*) MYPICTURE_DIR_PATH);
  476.     }
  477.     if (mmi_nsm_get_msg_type() == RINGTONE_MESSAGE)
  478.     {
  479.         sprintf(temp, "%c:\%s", MMI_PUBLIC_DRV, (S8*) MY_TONE_PATH);
  480.     }
  481.     mmi_nsm_create_dir(temp);
  482.     if (mmi_nsm_is_file_exist(fullfilenameInUnicode))
  483.     {
  484.         return NSM_DUPLICATE_FILE_4;
  485.     }
  486.     file_handle = FS_Open((const U16*)fullfilenameInUnicode, (FS_CREATE_ALWAYS | FS_READ_WRITE));
  487.     if (file_handle == FS_DISK_FULL)
  488.     {
  489.         return NSM_SPACE_FULL_3;
  490.     }
  491.     else if (file_handle == FS_INVALID_FILENAME)
  492.     {
  493.         return NSM_FILE_ERROR_5;
  494.     }
  495.     else if (file_handle < 0)
  496.     {
  497.         return NSM_COMMOM_ERROR_6;
  498.     }
  499.     if (mmi_nsm_get_msg_type() == PICTURE_MESSAGE)
  500.     {
  501.         BufferSize = mmi_pmsg_get_size_bmp_data((U8*) gNSMBuffer);     /* /-6;: JP for Operator Logo */
  502.         /* pfwrite((gNSMBuffer+6),      1, BufferSize, file_handle, &wByte); */
  503.         result = FS_Write(file_handle, (void*)(gNSMBuffer + 6), BufferSize, &wByte);
  504.     }
  505.     else
  506.     {
  507.         BufferSize = mmi_smrt_midi_file_size((U8*) gNSMBuffer);
  508.         /* write(gNSMBuffer,    1, BufferSize, file_handle, &wByte); */
  509.         result = FS_Write(file_handle, (void*)(gNSMBuffer), BufferSize, &wByte);
  510.     }
  511.     /* JP for Disk full File Manager issue */
  512.     if (result < 0)
  513.     {
  514.         if (result == FS_DISK_FULL)
  515.         {   /* Disk full */
  516.             FS_Close(file_handle);
  517.             FS_Delete((const U16*)fullfilenameInUnicode);
  518.             return NSM_SPACE_FULL_3;
  519.         }
  520.         FS_Close(file_handle);
  521.         return NSM_COMMOM_ERROR_6;
  522.     }
  523.     FS_Close(file_handle);
  524.     return NSM_SUCCESS_0;
  525. }
  526. /*****************************************************************************
  527.  * FUNCTION
  528.  *  mmi_nsm_is_file_exist
  529.  * DESCRIPTION
  530.  *  Checks for duplicate file
  531.  * PARAMETERS
  532.  *  fullfilenameInUnicode       [IN]        Absolute file name in Unicode
  533.  * RETURNS
  534.  * BOOL
  535.  *****************************************************************************/
  536. BOOL mmi_nsm_is_file_exist(S8 *fullfilenameInUnicode)
  537. {
  538.     /*----------------------------------------------------------------*/
  539.     /* Local Variables                                                */
  540.     /*----------------------------------------------------------------*/
  541.     FS_HANDLE h;
  542.     /*----------------------------------------------------------------*/
  543.     /* Code Body                                                      */
  544.     /*----------------------------------------------------------------*/
  545.     h = pfopen(fullfilenameInUnicode, PFS_READ);
  546.     if (h > 0)
  547.     {
  548.         pfclose(h);
  549.         return TRUE;
  550.     }
  551.     return FALSE;
  552. }
  553. #endif /* defined(__MMI_MYPICTURE__) || defined(__MMI_SMART_MESSAGE_MT__) || (defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)) */ 
  554. #if defined(__MMI_SMART_MESSAGE_MT__) || defined(__MMI_MYPICTURE__)
  555. extern S8 g_pmsg_TextInMessage[];
  556. /*****************************************************************************
  557.  * FUNCTION
  558.  *  mmi_mypic_entry_done_option
  559.  * DESCRIPTION
  560.  *  Display send options for picture message
  561.  * PARAMETERS
  562.  *  void
  563.  * RETURNS
  564.  *  void
  565.  *****************************************************************************/
  566. void mmi_mypic_entry_done_option(void)
  567. {
  568.     /*----------------------------------------------------------------*/
  569.     /* Local Variables                                                */
  570.     /*----------------------------------------------------------------*/
  571.     U8 *guiBuffer = NULL;
  572.     U16 numItems = 0;
  573.     U16 nStrItemList[MAX_SUB_MENUS];
  574.     /*----------------------------------------------------------------*/
  575.     /* Code Body                                                      */
  576.     /*----------------------------------------------------------------*/
  577.     EntryNewScreen(SCR_ID_MSG_SEND_OPTION, mmi_msg_exit_generic, mmi_mypic_entry_done_option, NULL);
  578.     g_msg_cntx.sendMessageCase = SEND_CASE_SEND_ONLY;   /* reset : JAI 27-11-2004 */
  579.     numItems = GetNumOfChild(MENU_ID_MYPIC_DONE);
  580.     GetSequenceStringIds(MENU_ID_MYPIC_DONE, nStrItemList);
  581.     SetParentHandler(MENU_ID_MYPIC_DONE);
  582.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  583.     SetMessagesCurrScrnID(SCR_ID_MSG_SEND_OPTION);
  584.     guiBuffer = GetCurrGuiBuffer(SCR_ID_MSG_SEND_OPTION);
  585.     ShowCategory52Screen(
  586.         STR_SEND_OPTIONS_CAPTION,
  587.         IMG_SMS_ENTRY_SCRN_CAPTION,
  588.         STR_GLOBAL_OK,
  589.         IMG_GLOBAL_OK,
  590.         STR_GLOBAL_BACK,
  591.         IMG_GLOBAL_BACK,
  592.         numItems,
  593.         nStrItemList,
  594.         (U16*) gIndexIconsImageList,
  595.         NULL,
  596.         0,
  597.         0,
  598.         guiBuffer);
  599. }
  600. /*****************************************************************************
  601.  * FUNCTION
  602.  *  highlight_mypic_send_handler
  603.  * DESCRIPTION
  604.  *  Highlight handler for My Picture - Send option
  605.  * PARAMETERS
  606.  *  void
  607.  * RETURNS
  608.  *  void
  609.  *****************************************************************************/
  610. void highlight_mypic_send_handler(void)
  611. {
  612.     /*----------------------------------------------------------------*/
  613.     /* Local Variables                                                */
  614.     /*----------------------------------------------------------------*/
  615.     /*----------------------------------------------------------------*/
  616.     /* Code Body                                                      */
  617.     /*----------------------------------------------------------------*/
  618.     mmi_msg_highlight_generic(
  619.         STR_GLOBAL_OK,
  620.         IMG_GLOBAL_OK,
  621.         STR_GLOBAL_BACK,
  622.         IMG_GLOBAL_BACK,
  623.         mmi_mypic_send_picmsg_to_only_entry,
  624.         GoBackHistory);
  625. }
  626. /*****************************************************************************
  627.  * FUNCTION
  628.  *  mmi_mypic_send_picmsg_to_only_entry
  629.  * DESCRIPTION
  630.  *  Send picture message to single destination
  631.  * PARAMETERS
  632.  *  void
  633.  * RETURNS
  634.  *  void
  635.  *****************************************************************************/
  636. void mmi_mypic_send_picmsg_to_only_entry(void)
  637. {
  638.     /*----------------------------------------------------------------*/
  639.     /* Local Variables                                                */
  640.     /*----------------------------------------------------------------*/
  641.     /*----------------------------------------------------------------*/
  642.     /* Code Body                                                      */
  643.     /*----------------------------------------------------------------*/
  644.     g_msg_cntx.sendMessageCase = SEND_CASE_SEND_ONLY;
  645.     memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
  646.     if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST))
  647.     {
  648.         pfnUnicodeStrcpy(g_msg_cntx.smsPhoneNumber, (S8*) PendingSaveSendData.number);
  649.     }
  650.     mmi_mypic_send_picmsg_to_entry();
  651. }
  652. /*****************************************************************************
  653.  * FUNCTION
  654.  *  mmi_mypic_send_picmsg_to_entry
  655.  * DESCRIPTION
  656.  *  Send picutre message to entry
  657.  * PARAMETERS
  658.  *  void
  659.  * RETURNS
  660.  *  void
  661.  *****************************************************************************/
  662. void mmi_mypic_send_picmsg_to_entry(void)
  663. {
  664.     /*----------------------------------------------------------------*/
  665.     /* Local Variables                                                */
  666.     /*----------------------------------------------------------------*/
  667.     /*----------------------------------------------------------------*/
  668.     /* Code Body                                                      */
  669.     /*----------------------------------------------------------------*/
  670.     if (IsScreenPresent(SCR_ID_MYPIC_DISPLAY))  /* JAI 06-12-2004 for My Pic */
  671.     {
  672.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MYPIC_DISPLAY);
  673.     }
  674.     else if (IsScreenPresent(SCR_ID_MSG_INBOX_MSG))
  675.     {
  676.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_INBOX_MSG);
  677.     }
  678.     else if (IsScreenPresent(SCR_ID_MSG_OUTBOX_MSG))
  679.     {
  680.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_OUTBOX_MSG);
  681.     }
  682.     else if (IsScreenPresent(SCR_ID_MSG_WRITE))
  683.     {
  684.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
  685.     }
  686.     else if (IsScreenPresent(SCR_ID_MSG_NUMBER))
  687.     {
  688.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_NUMBER);
  689.     }
  690.     else
  691.     {
  692.         SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_SENDING);
  693.     }
  694. }
  695. /* PMT JAI 24-11-2004 */
  696. /*****************************************************************************
  697.  * FUNCTION
  698.  *  highlight_mypic_addtext_handler
  699.  * DESCRIPTION
  700.  *  Highlight handler for My Picture - Add Text option
  701.  * PARAMETERS
  702.  *  void
  703.  * RETURNS
  704.  *  void
  705.  *****************************************************************************/
  706. void highlight_mypic_addtext_handler(void)
  707. {
  708.     /*----------------------------------------------------------------*/
  709.     /* Local Variables                                                */
  710.     /*----------------------------------------------------------------*/
  711.     /*----------------------------------------------------------------*/
  712.     /* Code Body                                                      */
  713.     /*----------------------------------------------------------------*/
  714.     SetLeftSoftkeyFunction(mmi_mypic_entry_addtext, KEY_EVENT_UP);
  715.     SetKeyHandler(mmi_mypic_entry_addtext, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  716.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  717.     SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  718. }
  719. /*****************************************************************************
  720.  * FUNCTION
  721.  *  mmi_mypic_entry_addtext
  722.  * DESCRIPTION
  723.  *  Entry function for Add Text
  724.  * PARAMETERS
  725.  *  void
  726.  * RETURNS
  727.  *  void
  728.  *****************************************************************************/
  729. void mmi_mypic_entry_addtext(void)
  730. {
  731.     /*----------------------------------------------------------------*/
  732.     /* Local Variables                                                */
  733.     /*----------------------------------------------------------------*/
  734.     U8 *guiBuffer;
  735.     U16 StrID;
  736.     /*----------------------------------------------------------------*/
  737.     /* Code Body                                                      */
  738.     /*----------------------------------------------------------------*/
  739.     EntryNewScreen(SCR_ID_NSM_EDITOR, NULL, mmi_mypic_entry_addtext, NULL);
  740.     SetMessagesCurrScrnID(SCR_ID_NSM_EDITOR);
  741.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  742.     guiBuffer = GetCurrGuiBuffer(SCR_ID_NSM_EDITOR);
  743.     if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST))
  744.     {
  745.         StrID = STR_ID_PICMSG_EDIT_TEXT;
  746.     }
  747.     else
  748.     {
  749.         StrID = STR_ID_MYPIC_ADDTEXT;
  750.     }
  751.     ShowCategory5Screen(
  752.         StrID,
  753.         0,
  754.         STR_GLOBAL_OPTIONS,
  755.         0,
  756.         STR_GLOBAL_BACK,
  757.         0,
  758.         INPUT_TYPE_ALPHANUMERIC_SENTENCECASE,
  759.         (U8*) gaddtext_buffer,
  760.         129,
  761.         guiBuffer);
  762.     /* SetLeftSoftkeyFunction( mmi_mypic_entry_done,        KEY_EVENT_UP); //PMT JAI : 23122004 */
  763.     SetLeftSoftkeyFunction(mmi_mypic_insert_text_options, KEY_EVENT_UP);
  764.     SetCategory5RightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  765.     SetKeyHandler(mmi_mypic_entry_done_option, KEY_SEND, KEY_EVENT_UP);
  766. }
  767. /*****************************************************************************
  768.  * FUNCTION
  769.  *  mmi_mypic_insert_text_options
  770.  * DESCRIPTION
  771.  *  
  772.  * PARAMETERS
  773.  *  void
  774.  * RETURNS
  775.  *  void
  776.  *****************************************************************************/
  777. void mmi_mypic_insert_text_options(void)
  778. {
  779.     /*----------------------------------------------------------------*/
  780.     /* Local Variables                                                */
  781.     /*----------------------------------------------------------------*/
  782.     U16 NumOfItems = 0;
  783.     U8 *guiBuffer = NULL;
  784.     U16 nStrItemsList[2];
  785.     /*----------------------------------------------------------------*/
  786.     /* Code Body                                                      */
  787.     /*----------------------------------------------------------------*/
  788.     EntryNewScreen(SCR_ID_EDIT_OPTIONS, mmi_msg_exit_generic, mmi_mypic_insert_text_options, NULL);
  789.     SetParentHandler(MENU_ID_MYPIC_INSERT_TEXT_OPTION);
  790.     SetMessagesCurrScrnID(SCR_ID_EDIT_OPTIONS);
  791.     NumOfItems = GetNumOfChild(MENU_ID_MYPIC_INSERT_TEXT_OPTION);
  792.     GetSequenceStringIds(MENU_ID_MYPIC_INSERT_TEXT_OPTION, nStrItemsList);
  793.     guiBuffer = GetCurrGuiBuffer(SCR_ID_EDIT_OPTIONS);
  794.     RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  795.     ShowCategory52Screen(
  796.         STR_GLOBAL_OPTIONS,
  797.         IMG_SMS_ENTRY_SCRN_CAPTION,
  798.         STR_GLOBAL_OK,
  799.         IMG_GLOBAL_OK,
  800.         STR_GLOBAL_BACK,
  801.         IMG_GLOBAL_BACK,
  802.         NumOfItems,
  803.         nStrItemsList,
  804.         (U16*) gIndexIconsImageList,
  805.         NULL,
  806.         0,
  807.         0,
  808.         guiBuffer);
  809. }
  810. /*****************************************************************************
  811.  * FUNCTION
  812.  *  highlight_mypic_insert_text_done
  813.  * DESCRIPTION
  814.  *  
  815.  * PARAMETERS
  816.  *  void
  817.  * RETURNS
  818.  *  void
  819.  *****************************************************************************/
  820. void highlight_mypic_insert_text_done(void)
  821. {
  822.     /*----------------------------------------------------------------*/
  823.     /* Local Variables                                                */
  824.     /*----------------------------------------------------------------*/
  825.     /*----------------------------------------------------------------*/
  826.     /* Code Body                                                      */
  827.     /*----------------------------------------------------------------*/
  828.     SetLeftSoftkeyFunction(mmi_mypic_entry_done, KEY_EVENT_UP);
  829.     SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  830. }
  831. /*****************************************************************************
  832.  * FUNCTION
  833.  *  mmi_mypic_entry_done
  834.  * DESCRIPTION
  835.  *  Takes user back to MyPicture List
  836.  * PARAMETERS
  837.  *  void
  838.  * RETURNS
  839.  *  void
  840.  *****************************************************************************/
  841. void mmi_mypic_entry_done(void)
  842. {
  843.     /*----------------------------------------------------------------*/
  844.     /* Local Variables                                                */
  845.     /*----------------------------------------------------------------*/
  846.     /*----------------------------------------------------------------*/
  847.     /* Code Body                                                      */
  848.     /*----------------------------------------------------------------*/
  849.     /* Jai 1-12-2004 */
  850.     if (IsScreenPresent(SCR_ID_MSG_OUTBOX_LIST))
  851.     {
  852.         UnicodeToAnsii((S8*) g_pmsg_TextInMessage, (S8*) gaddtext_buffer);
  853.     }
  854.     GoBacknHistory(2);
  855. }
  856. #endif /* defined(__MMI_SMART_MESSAGE_MT__) || defined(__MMI_MYPICTURE__) */ 
  857. #endif /* __MOD_SMSAL__ */