JPushInboxCommonUI.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:43k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * PushInboxCommonUI.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file is common functions calls to be used by both service inbox and UM.
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #ifndef _MMI_PUSHINBOXCOMMONUI_C
- #define _MMI_PUSHINBOXCOMMONUI_C
- #include "MMI_features.h"
- #if defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT)
- #include "PixtelDataTypes.h"
- #include "Unicodexdcl.h"
- #include "HistoryGprot.h"
- #include "GlobalDefs.h"
- #include "CommonScreens.h"
- #include "SettingProfile.h"
- #include "NVRAMType.h"
- #include "NVRAMProt.h"
- #include "NVRAMEnum.h"
- #include "worldclock.h" /* Vivek - 01092006 */
- #include "wgui_categories.h"
- #include "wgui_categories_inputs.h"
- #include "wap_ps_struct.h"
- #include "wapadp.h"
- #include "ddl.h"
- #include "jcal.h"
- #include "jdd_memapi.h"
- #include "jdd_BrowserConfig.h" /* Added by Vivek - 08-nov-2006 */
- #include "jdi_communicator.h"
- #include "jdi_BrowserDatatype.h"
- #include "JBrowserMMIDefs.h"
- #include "JBrowserMMIProts.h"
- #include "JBrowserMMIGprots.h"
- #include "JBrowserMMITypes.h"
- // #include "JBrowserStartup.h"
- #include "wgui_status_icons.h"
- /* PMT DARA PROFILE HANDLER 020106 */
- #include "JProfileHandlerTypes.h"
- #include "JProfileHandlerProts.h"
- #include "UnifiedMessageDef.h"
- #include "JPushInboxCommonAPIs.h"
- #include "JPushInboxCommonUI.h"
- #include "time.h"
- #include "app_datetime.h"
- #include "DateTimeGprot.h"
- #include "PhoneSetupGprots.h"
- #include "CallManagementGprot.h"
- SERVICE_VALUE *g_current_service_message = NULL;
- SERVICE_VALUE **g_brw_service_msg_list_p = NULL;
- U16 g_brw_index_current_highlighted_item = 0;
- U8 *g_message_buffer = NULL;
- S32 g_max_push_messages = 0;
- /*
- * We will set this flag when a push delete notification will come. So that
- * on idle 'new service message' pop can be avoid in case of push
- * replacement. This flag will be reset at the following place
- * - While reading the push message.
- * - While displaying the Inbox.
- * - While entering to the idle screen.
- * - While displaying the UM Main Screen (Only for UM)
- */
- MMI_BOOL g_mmi_brw_delete_push_notification = MMI_FALSE;
- extern void mmi_um_brw_delete_all_push_messages_ind(void);
- extern void mmi_um_brw_highlight_push_messages_ind(void);
- /*****************************************************************************
- * FUNCTION
- * mmi_brw_initialize_push_message_list
- * DESCRIPTION
- * This function is responsible for initializing th push message list.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_brw_initialize_push_message_list(void)
- {
- /* Get maximum number of push mesages supported */
- #ifdef __MMI_UNIFIED_MESSAGE__
- g_max_push_messages = MMI_UM_MAX_GET_LIST_MSG_NUMBER;
- #else /* __MMI_UNIFIED_MESSAGE__ */
- g_max_push_messages = jdd_BrowserConfigGetMaxPushMessage();
- #endif /* __MMI_UNIFIED_MESSAGE__ */
- g_brw_service_msg_list_p = (SERVICE_VALUE **) jdd_MemAlloc(g_max_push_messages,sizeof(SERVICE_VALUE *));
- /* TODO : null check */
- jc_memset(g_brw_service_msg_list_p, 0, g_max_push_messages * sizeof(SERVICE_VALUE *));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_brw_deinitialize_push_message_list
- * DESCRIPTION
- * This function is responsible for freeing the push message list.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_brw_deinitialize_push_message_list(void)
- {
- if (g_brw_service_msg_list_p != NULL)
- {
- jdd_MemFree(g_brw_service_msg_list_p);
- g_brw_service_msg_list_p = NULL;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_brw_push_free_service_value_struct
- * DESCRIPTION
- * This function is responsible for freeing service value struct.
- * PARAMETERS
- * service_message [IN] Service value structure.
- * about push messages.(?)(?)
- * RETURNS
- * returns local time.(?)
- *
- * Note : function is freeing only those field which are copied in(?)
- * mmi_brw_push_service_value_struct_dup. - Vivek 13072006(?)
- *****************************************************************************/
- void mmi_brw_push_free_service_value_struct(SERVICE_VALUE **service_message)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((NULL == service_message) || (NULL == *service_message))
- {
- return;
- }
- if ((*service_message)->pmHref != NULL)
- {
- jdd_MemFree((*service_message)->pmHref);
- (*service_message)->pmHref = NULL;
- }
- if ((*service_message)->pSICreated != NULL)
- {
- jdd_MemFree((*service_message)->pSICreated);
- (*service_message)->pSICreated = NULL;
- }
- if ((*service_message)->pSIExpires != NULL)
- {
- jdd_MemFree((*service_message)->pSIExpires);
- (*service_message)->pSIExpires = NULL;
- }
- if ((*service_message)->pSIRcvd != NULL)
- {
- jdd_MemFree((*service_message)->pSIRcvd);
- (*service_message)->pSIRcvd = NULL;
- }
- if ((*service_message)->pmMessage != NULL)
- {
- jdd_MemFree((*service_message)->pmMessage);
- (*service_message)->pmMessage = NULL;
- }
- jdd_MemFree(*service_message);
- *service_message = NULL;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_brw_push_service_value_struct_dup
- * DESCRIPTION
- * This function is responsible for creating the copy of service value structure.
- * PARAMETERS
- * service_message [?]
- * SI_TIME(?) [IN] Time structure filled with GMT time.
- * about push messages.(?)(?)
- * RETURNS
- * returns local time.
- * Note : We are copying only those value which are needed in MMI. - Vivek 13072006.
- *****************************************************************************/
- SERVICE_VALUE *mmi_brw_push_service_value_struct_dup(SERVICE_VALUE *service_message)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- SERVICE_VALUE *dup_service_message = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- dup_service_message = (SERVICE_VALUE*) jdd_MemAlloc(1, sizeof(SERVICE_VALUE));
- if (NULL == dup_service_message)
- {
- return NULL;
- }
- dup_service_message->service_flag = service_message->service_flag;
- if (service_message->pmMessage != NULL)
- {
- dup_service_message->pmMessage =
- (JC_CHAR*) jdd_MemAlloc(jc_tcslen(service_message->pmMessage) + 1, sizeof(JC_CHAR));
- if (NULL == dup_service_message->pmMessage)
- {
- mmi_brw_push_free_service_value_struct(&dup_service_message);
- return NULL;
- }
- jc_tcscpy(dup_service_message->pmMessage, service_message->pmMessage);
- }
- if (service_message->pmHref != NULL)
- {
- dup_service_message->pmHref = (JC_CHAR*) jdd_MemAlloc(jc_tcslen(service_message->pmHref) + 1, sizeof(JC_CHAR));
- if (NULL == dup_service_message->pmHref)
- {
- mmi_brw_push_free_service_value_struct(&dup_service_message);
- return NULL;
- }
- jc_tcscpy(dup_service_message->pmHref, service_message->pmHref);
- }
- if (NULL != service_message->pSICreated)
- {
- dup_service_message->pSICreated = (SI_TIME*) jdd_MemAlloc(1, sizeof(SI_TIME));
- if (NULL == dup_service_message->pSICreated)
- {
- mmi_brw_push_free_service_value_struct(&dup_service_message);
- return NULL;
- }
- jc_memmove(dup_service_message->pSICreated, service_message->pSICreated, sizeof(SI_TIME));
- }
- if (NULL != service_message->pSIRcvd)
- {
- dup_service_message->pSIRcvd = (SI_TIME*) jdd_MemAlloc(1, sizeof(SI_TIME));
- if (NULL == dup_service_message->pSIRcvd)
- {
- mmi_brw_push_free_service_value_struct(&dup_service_message);
- return NULL;
- }
- jc_memmove(dup_service_message->pSIRcvd, service_message->pSIRcvd, sizeof(SI_TIME));
- }
- if (NULL != service_message->pSIExpires)
- {
- dup_service_message->pSIExpires = (SI_TIME*) jdd_MemAlloc(1, sizeof(SI_TIME));
- if (NULL == dup_service_message->pSIExpires)
- {
- mmi_brw_push_free_service_value_struct(&dup_service_message);
- return NULL;
- }
- jc_memmove(dup_service_message->pSIExpires, service_message->pSIExpires, sizeof(SI_TIME));
- }
- return dup_service_message;
- }
- /*****************************************************************************
- * FUNCTION
- * convert_gmt_in_to_local_time
- * DESCRIPTION
- * This function is responsible for converting GMT time in to local time.
- * PARAMETERS
- * gmt_time_p [?]
- * SI_TIME(?) [IN] Time structure filled with GMT time.
- * about push messages.(?)(?)
- * RETURNS
- * returns local time.
- *****************************************************************************/
- static SI_TIME convert_gmt_in_to_local_time(SI_TIME *gmt_time_p)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 tzdiff = 0;
- U32 timeSecs = 0;
- U32 local_time = 0;
- FLOAT tz = 0.0;
- MYTIME result = {0};
- MYTIME currGMTTime = {0};
- SI_TIME local_time_p = {0};
- applib_time_struct time;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (NULL == gmt_time_p)
- {
- return local_time_p;
- }
- currGMTTime.nSec = gmt_time_p->seconds;
- currGMTTime.nMin = gmt_time_p->minute;
- currGMTTime.nHour = gmt_time_p->hour;
- currGMTTime.nDay = gmt_time_p->day;
- currGMTTime.nMonth = gmt_time_p->month;
- currGMTTime.nYear = gmt_time_p->year;
- timeSecs = (U32) mmi_dt_mytime_2_utc_sec(&currGMTTime, MMI_TRUE);
- tz = mmi_dt_get_tz();
- if(tz < 0)
- {
- time = applib_conv_tz_to_mytime(tz * (-1));
- }
- else
- {
- time = applib_conv_tz_to_mytime(tz);
- }
- tzdiff = time.nHour * 3600 + time.nMin * 60 + time.nSec;
- if(tz > 0)
- {
- local_time = timeSecs + tzdiff;
- }
- else
- {
- local_time = timeSecs - tzdiff;
- }
- mmi_dt_utc_sec_2_mytime(local_time, &result, MMI_TRUE);
- local_time_p.year = result.nYear;
- local_time_p.month = result.nMonth;
- local_time_p.day = result.nDay;
- local_time_p.hour = result.nHour;
- local_time_p.minute = result.nMin;
- local_time_p.seconds = result.nSec;
- return local_time_p;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_brw_create_push_display_format
- * DESCRIPTION
- * This function is responsible for creating the formatted Push message string.
- * Push message should display in the following format.
- * SI message should be display in the following format(example)
- *
- * 10 jan 2006 12:00 (If created date is not present then received date should be here)
- * Expires:
- * 20 Jun 2006 12:00
- * URL:
- * http://www.exampleSISL.com
- * Message:
- * SISL message Body
- *
- * for SL messages only URL should display.
- * PARAMETERS
- * push_message_struct [IN] Structure pointer which contatins all the information
- * about push messages.(?)
- * RETURNS
- * returns buffer, which contains the formatted string of push messages.
- *****************************************************************************/
- PS8 mmi_brw_create_push_display_format(SERVICE_VALUE *push_message_struct)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 message_length = 0;
- S16 message_href_length = 0;
- S16 meassage_body_length = 0;
- PS8 ucs2_message_buffer = NULL;
- S8 ucs2_time_string[MMI_BRW_SI_DATE_N_TIME_STRING_LENGTH] = {0};
- SI_TIME sisl_local_time = {0};
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (push_message_struct->service_flag == SERVICE_INDICATION)
- {
- meassage_body_length = pfnUnicodeStrlen((const S8*)push_message_struct->pmMessage);
- message_href_length = pfnUnicodeStrlen((const S8*)push_message_struct->pmHref);
- /* Calculate the length of the message */
- message_length = message_href_length + meassage_body_length +
- MMI_BRW_SI_DATE_N_TIME_STRING_LENGTH +
- pfnUnicodeStrlen((const S8*)GetString(STR_ID_BRW_PUSH_MESSAGE)) +
- pfnUnicodeStrlen((const S8*)GetString(STR_ID_BRW_PUSH_URL));
- if (NULL != push_message_struct->pSIExpires)
- {
- message_length += (MMI_BRW_SI_DATE_N_TIME_STRING_LENGTH +
- pfnUnicodeStrlen((const S8*)GetString(STR_ID_BRW_PUSH_EXPIRES)));
- }
- /* adding 1 for ' ' */
- ucs2_message_buffer = (PS8) jdd_MemAlloc((message_length + 1), ENCODING_LENGTH);
- /* todo : check null value */
- if (NULL != push_message_struct->pSICreated)
- {
- sisl_local_time = convert_gmt_in_to_local_time(push_message_struct->pSICreated);
- }
- else /* If date Created is not present, use date received. */
- {
- sisl_local_time = convert_gmt_in_to_local_time(push_message_struct->pSIRcvd);
- }
- mmi_brw_create_ucs2_push_time_format_string(&sisl_local_time, ucs2_time_string);
- pfnUnicodeStrcpy(ucs2_message_buffer, ucs2_time_string);
- pfnUnicodeStrcat(ucs2_message_buffer, "n");
- if (NULL != push_message_struct->pSIExpires)
- {
- pfnUnicodeStrcat(ucs2_message_buffer, GetString(STR_ID_BRW_PUSH_EXPIRES));
- pfnUnicodeStrcat(ucs2_message_buffer, "n");
- sisl_local_time = convert_gmt_in_to_local_time(push_message_struct->pSIExpires);
- mmi_brw_create_ucs2_push_time_format_string(&sisl_local_time, ucs2_time_string);
- pfnUnicodeStrcat(ucs2_message_buffer, ucs2_time_string);
- pfnUnicodeStrcat(ucs2_message_buffer, "n");
- }
- pfnUnicodeStrcat((S8*) ucs2_message_buffer, GetString(STR_ID_BRW_PUSH_URL));
- pfnUnicodeStrcat(ucs2_message_buffer, "n");
- pfnUnicodeStrcat((S8*) ucs2_message_buffer, (const S8*)push_message_struct->pmHref);
- pfnUnicodeStrcat((S8*) ucs2_message_buffer, "n");
- if (0 != meassage_body_length)
- {
- pfnUnicodeStrcat((S8*) ucs2_message_buffer, GetString(STR_ID_BRW_PUSH_MESSAGE));
- pfnUnicodeStrcat(ucs2_message_buffer, "n");
- pfnUnicodeStrcat((S8*) ucs2_message_buffer, (const S8*)push_message_struct->pmMessage);
- }
- }
- else if (push_message_struct->service_flag == SERVICE_LOADING)
- {
- message_href_length = pfnUnicodeStrlen((const S8*)push_message_struct->pmHref);
- message_length = message_href_length + pfnUnicodeStrlen((const S8*)GetString(STR_ID_BRW_PUSH_URL));
- ucs2_message_buffer = (PS8) jdd_MemAlloc((message_length + 2), ENCODING_LENGTH);
- pfnUnicodeStrcpy(ucs2_message_buffer, GetString(STR_ID_BRW_PUSH_URL));
- pfnUnicodeStrcat(ucs2_message_buffer, "n");
- pfnUnicodeStrcat((S8*) ucs2_message_buffer, (const S8*)push_message_struct->pmHref);
- }
- else
- {
- /* error */
- }
- return ucs2_message_buffer;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_brw_create_ucs2_push_time_format_string
- * DESCRIPTION
- * This function is responsible for generating time string (As given in the following example),
- * which will be displayed with push messages.
- * Ex. : 20 Jun 2006 12:00
- * PARAMETERS
- * sisl_time [?]
- * ucs2_time_string [IN]
- * time(?) [IN] Time structure.
- * RETURNS
- * returns buffer, which contains the formatted string of time for push messages.(?)
- *****************************************************************************/
- void mmi_brw_create_ucs2_push_time_format_string(SI_TIME *sisl_time, PS8 ucs2_time_string)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYTIME time = {0};
- UI_character_type temp_time_buffer[20] = {0};
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- time.nYear = sisl_time->year;
- time.nMonth = sisl_time->month;
- time.nDay = sisl_time->day;
- time.nHour = sisl_time->hour;
- time.nMin = sisl_time->minute;
- time.nSec = sisl_time->seconds;
- date_string(&time, temp_time_buffer, DT_IDLE_SCREEN);
- pfnUnicodeStrncpy((S8*) ucs2_time_string, (S8*) temp_time_buffer, pfnUnicodeStrlen((const S8*)temp_time_buffer));
- pfnUnicodeStrncat((S8*) ucs2_time_string, (S8*) " ", 1);
- time_string(&time, temp_time_buffer, DT_IDLE_SCREEN);
- pfnUnicodeStrncat((S8*) ucs2_time_string, (S8*) temp_time_buffer, pfnUnicodeStrlen((const S8*)temp_time_buffer));
- pfnUnicodeStrncat((S8*) ucs2_time_string, (S8*) "