⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jbrowsermmiaddresshistory.c

📁 MTK手机平台的MMI部分的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*****************************************************************************
*  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:
 * ---------
 * JBrowserMMIAddressHistory.c
 *
 * Project:
 * --------
 *   MAUI
 *
 * Description:
 * ------------
 *   This file is intends for address history implementation.
 *
 * 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!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

#ifndef _MMI_JBROWSERMMIADDRESSHISTORY_C
#define _MMI_JBROWSERMMIADDRESSHISTORY_C

/*  Include: MMI header file */
#include "MMI_features.h"
#if defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT)
#include "PixtelDataTypes.h"
#include "Unicodexdcl.h"
#include "HistoryGprot.h"
#include "GlobalDefs.h"
#include "SettingProfile.h"
#include "DebugInitDef.h"
#include "CommonScreens.h"
#include "EventsGprot.h"
#include "wgui_inputs.h"
#include "wgui_categories.h"
#include "wgui_categories_inputs.h"
#include "OrganizerDef.h"
#include "DateTimeGprot.h"
#include "TimerEvents.h"
#include "wgui_categories_popup.h"
#include "settingGprots.h"
#include "JBrowserMMIDefs.h"
#include "JBrowserMMIProts.h"
#include "JBrowserMMITypes.h"
#include "JBrowserMMIGprots.h"

/*  Include: NVRAM header file */
#include "NVRAMType.h"
#include "NVRAMProt.h"
#include "NVRAMEnum.h"

/*  Include: Jataayu header file */
#include "ddl.h"
#include "jcal.h"
#include "jdd_memapi.h"
#include "browserlayout.h"
#include "jdi_servicehandler.h"
#include "fsm.h"

U8 g_brw_add_hist_flag;
static U8 g_brw_hist_selected_title[(BRW_ADDRESS_HISTORY_MAX_TITLE_LENGTH) * ENCODING_LENGTH];
static U8 g_brw_hist_selected_url[(BRW_ADDRESS_HISTORY_MAX_URL_LENGTH) * ENCODING_LENGTH];
U8 g_brw_enter_add_flag;    /* added by tk to set the highlighter to a 2nd position */

/* Extern Function,variables */
extern pBOOL GetUCS2Flag(PS8 buffer);


/*****************************************************************************
 * FUNCTION
 *  mmi_brw_entry_enter_address
 * DESCRIPTION
 *  Entry function for enter address menu
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_brw_entry_enter_address(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U8 *guiBuffer = NULL;
    U16 record_count;
    S16 NvramError;
    U8 highlight_index = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* Read address history list from NVRAM if not already read */
    if ((g_brw_cntx.address_history_title_p == NULL) && (g_brw_cntx.address_history_url_p == NULL))
    {
        g_brw_cntx.address_history_title_p =
            (nvram_brw_hist_title_struct*) jdd_MemAlloc(
                                            NVRAM_BRW_NUM_ADDRESS_HISTORY_TITLE_RECORDS,
                                            NVRAM_BRW_ADDRESS_HISTORY_TITLE_SIZE);
        g_brw_cntx.address_history_url_p =
            (nvram_brw_hist_url_struct*) jdd_MemAlloc(
                                            NVRAM_BRW_NUM_ADDRESS_HISTORY_URL_RECORDS,
                                            NVRAM_BRW_ADDRESS_HISTORY_URL_SIZE);

        memset(
            g_brw_cntx.address_history_title_p,
            0,
            (NVRAM_BRW_ADDRESS_HISTORY_TITLE_SIZE * NVRAM_BRW_NUM_ADDRESS_HISTORY_TITLE_RECORDS));
        memset(
            g_brw_cntx.address_history_url_p,
            0,
            (NVRAM_BRW_ADDRESS_HISTORY_URL_SIZE * NVRAM_BRW_NUM_ADDRESS_HISTORY_URL_RECORDS));

        for (record_count = 1; record_count <= NVRAM_BRW_NUM_ADDRESS_HISTORY_TITLE_RECORDS; record_count++)
        {
            ReadRecord(
                NVRAM_EF_BRW_ADDRESS_HISTORY_TITLE_LID,
                record_count,
                &g_brw_cntx.address_history_title_p[(record_count - 1) * TITLES_PER_RECORD],
                NVRAM_BRW_ADDRESS_HISTORY_TITLE_SIZE,
                &NvramError);
        }

        for (record_count = 1; record_count <= NVRAM_BRW_NUM_ADDRESS_HISTORY_URL_RECORDS; record_count++)
        {
            ReadRecord(
                NVRAM_EF_BRW_ADDRESS_HISTORY_URL_LID,
                record_count,
                &g_brw_cntx.address_history_url_p[(record_count - 1) * URLS_PER_RECORD],
                NVRAM_BRW_ADDRESS_HISTORY_URL_SIZE,
                &NvramError);
        }

        /* Calculate the number of entries */
        mmi_brw_calculate_number_of_address_history_items_stored();
    }

    /* Open editor if no entries are present */
    if (g_brw_cntx.total_address_history_items == 0)
    {
        AnsiiToUnicodeString((S8*) g_brw_hist_selected_url, (S8*) ("http://"));
        mmi_brw_entry_enter_url();
    }
    else
    {
        EntryNewScreen(SCR_ID_BRW_ENTER_ADDRESS, NULL, mmi_brw_entry_enter_address, NULL);
        guiBuffer = GetCurrGuiBuffer(SCR_ID_BRW_ENTER_ADDRESS);
        /* added by tk */
        if (g_brw_enter_add_flag/* && guiBuffer != NULL && guiBuffer[2] != 0*/)
        {
            guiBuffer = NULL;
            g_brw_enter_add_flag = 0;
            highlight_index = 1;
        }
        
		RegisterHighlightHandler(mmi_brw_enter_address_scr_highlight_hdlr);

        ShowCategory184Screen(
            STR_ID_BRW_ENTER_ADDRESS,
            GetRootTitleIcon(SERVICES_WAP_MENU_ID),
            STR_GLOBAL_OK,
            0,
            STR_GLOBAL_BACK,
            0,
            g_brw_cntx.total_address_history_items + 1,
            mmi_brw_address_history_list_get_item,
            0,
            highlight_index,
            guiBuffer);

        SetLeftSoftkeyFunction(mmi_brw_hist_highlighted_item, KEY_EVENT_UP);
        SetKeyHandler(mmi_brw_hist_highlighted_item, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);

        SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
        SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
    }
}


/*****************************************************************************
 * FUNCTION
 *  mmi_brw_enter_address_scr_highlight_hdlr
 * DESCRIPTION
 *   --
 * PARAMETERS
 *  index		[IN]
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_brw_enter_address_scr_highlight_hdlr(S32 index)
{
	if(index == 0)
	{
		ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
	}
	else
	{
		ChangeLeftSoftkey(STR_GLOBAL_OPTIONS, IMG_GLOBAL_OPTIONS);
	}
}


/*****************************************************************************
 * FUNCTION
 *  mmi_brw_calculate_number_of_address_history_items_stored
 * DESCRIPTION
 *  Function to calculate the total number of address history items stored
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_brw_calculate_number_of_address_history_items_stored(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 history_count = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    for (history_count = 0; history_count < BRW_MAX_ADDRESS_HISTORY; history_count++)
    {
        if ((strlen((S8*) g_brw_cntx.address_history_title_p[history_count].title)) == 0)
        {
            /* If both title and url are '0' exit the loop */
            if ((strlen((S8*) g_brw_cntx.address_history_url_p[history_count].url)) == 0)
            {
                break;
            }
        }

        g_brw_cntx.total_address_history_items++;
    }
}


/*****************************************************************************
 * FUNCTION
 *  mmi_brw_address_history_list_get_item
 * DESCRIPTION
 *  Item call back function for dynamic list of address history
 * PARAMETERS
 *  item_index          [IN]        Highlighted item index
 *  str_buff            [IN]        Buffer to be shown
 *  img_buff_p          [?]         [?]         image to be shown
 *  str_img_mask        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
pBOOL mmi_brw_address_history_list_get_item(S32 item_index, UI_string_type str_buff, PU8 *img_buff_p, U8 str_img_mask)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S8 pOutBuffer[8];

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if ((item_index < 0) || (item_index > BRW_MAX_ADDRESS_HISTORY))
    {
        return FALSE;
    }

    if (item_index == 0)
    {
        pfnUnicodeStrcpy((S8*) str_buff, GetString(STR_ID_BRW_ENTER_ADDRESS));
    }
    else
    {
        /* Display title if settings option is 'Show history by title' */
        /* added by tk */
        if (g_brw_cntx.show_history_as_url)
            {
                /* truncate the URL to 38 charactes and append three '.'(dots) if the length of URL exceeds 
                   MAX_SUBMENU_CHARACTERS charactes */
                if (strlen((S8*) g_brw_cntx.address_history_url_p[item_index - 1].url) > MAX_SUBMENU_CHARACTERS)
                {
                    AnsiiNToUnicodeString(
                        (S8*) str_buff,
                        (S8*) g_brw_cntx.address_history_url_p[item_index - 1].url,
                        BRW_MAX_VISIBLE_URL_LENGTH);
                    str_buff[BRW_MAX_VISIBLE_URL_LENGTH] = '\0';
                    AnsiiToUnicodeString(pOutBuffer, (S8*) "...");
                    pfnUnicodeStrcat((S8*) str_buff, (S8*) pOutBuffer);
                }
                else
                {
                    AnsiiToUnicodeString((S8*) str_buff, (S8*) g_brw_cntx.address_history_url_p[item_index - 1].url);
                }
            }
        else
        {
            if ((g_brw_cntx.address_history_title_p[item_index - 1].dcs == BRW_DCS_ASCII) &&
                (strlen((S8*) g_brw_cntx.address_history_title_p[item_index - 1].title) != 0))
            {
                AnsiiToUnicodeString((S8*) str_buff, (S8*) g_brw_cntx.address_history_title_p[item_index - 1].title);

        }
            else if ((g_brw_cntx.address_history_title_p[item_index - 1].dcs == BRW_DCS_UCS) &&
                     (pfnUnicodeStrlen((S8*) g_brw_cntx.address_history_title_p[item_index - 1].title) != 0))
            {
                pfnUnicodeStrcpy((S8*) str_buff, (S8*) g_brw_cntx.address_history_title_p[item_index - 1].title);
            }
            /* tk end */
        else
        {
            /* truncate the URL to 38 charactes and append three '.'(dots) if the length of URL exceeds 
               MAX_SUBMENU_CHARACTERS charactes */
            if (strlen((S8*) g_brw_cntx.address_history_url_p[item_index - 1].url) > MAX_SUBMENU_CHARACTERS)
            {
                AnsiiNToUnicodeString(
                    (S8*) str_buff,
                    (S8*) g_brw_cntx.address_history_url_p[item_index - 1].url,
                    BRW_MAX_VISIBLE_URL_LENGTH);
                str_buff[BRW_MAX_VISIBLE_URL_LENGTH] = '\0';
                AnsiiToUnicodeString(pOutBuffer, (S8*) "...");
                pfnUnicodeStrcat((S8*) str_buff, (S8*) pOutBuffer);
            }
            else
            {
                AnsiiToUnicodeString((S8*) str_buff, (S8*) g_brw_cntx.address_history_url_p[item_index - 1].url);
            }
        }
    }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -