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

📄 mmibookutils.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*******************************************************************************

					CONDAT (UK)

********************************************************************************                                                                              

 This software product is the property of Condat (UK) Ltd and may not be
 disclosed to any third party without the express permission of the owner.                                 
                                                                              
********************************************************************************

 $Project name:	Basic MMI                                                      
 $Project code:	BMI (6349)                                                           
 $Module:		PhoneBook
 $File:		    MmiBookUtils.c
 $Revision:		1.0                                                       
                                                                              
 $Author:		Condat(UK)                                                         
 $Date:		    25/10/00                                                      
                                                                               
********************************************************************************
                                                                              
 Description:
 
    This module provides utility function for use in the
    phone book application
                        
********************************************************************************

 $History: MmiBookUtils.c

	25/10/00			Original Condat(UK) BMI version.	
	   
 $End

*******************************************************************************/



/*******************************************************************************
                                                                              
                                Include Files
                                                                              
*******************************************************************************/
#define ENTITY_MFW

/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#if defined (NEW_FRAME)

#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"

#else

#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"

#endif

#include "mfw_sys.h"

#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_lng.h"
/* SPR#1428 - SH - New Editor changes */
#ifndef NEW_EDITOR
#include "mfw_edt.h"
#endif
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_tim.h"

#include "mfw_sim.h"
#include "mfw_cm.h"
#include "mfw_nm.h"
#include "mfw_phb.h"
#include "mfw_mme.h"
#include "mfw_sat.h"
#include "mfw_sms.h"

#include "dspl.h"

#include "ksd.h"
#include "psa.h"

#include "MmiMain.h"
#include "MmiBookController.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"



#include "MmiMenu.h"
#include "MmiCall.h"
#include "MmiIcons.h"
#include "MmiIdle.h"

#include "MmiSoftKeys.h"
#include "MmiSounds.h"
#include "MmiIdle.h"
#include "MmiNetwork.h"
#include "MmiSat_i.h"
#include "MmiAoc.h"

#include "gdi.h"
#include "audio.h"

#include "cus_aci.h"
#include "p_sim.h"
#include "mfw_ffs.h"
#include "MmiTimers.h"

#include "MmiBookShared.h"

#include "mmicolours.h"
#include "MmiSmsRead.h"/*MC , SPR 1242 */


/*******************************************************************************
                                                                              
                                Private data elements
                                                                              
*******************************************************************************/

static T_MFW_UPN_LIST   *upnList = NULL;

/* SPR#1112 - SH - This is redundant */
//static T_phbk           *GlobalPhoneBookHandle = NULL;

/* SPR#1112 - SH - Internal phonebook flag */
#ifdef INT_PHONEBOOK
static UBYTE ipbCopyIndex = 0;
static UBYTE ipbMove = FALSE;
static T_MFW_HND ipbWin = NULL;
#endif


/*******************************************************************************
                                                                              
                                Private Methods
                                                                              
*******************************************************************************/

/*******************************************************************************

 $Function:    	changeName

 $Description:	Change a phone book entry if we have a valid book selected
 
 $Returns:		status of change, or MWB_PHB_FAIL if an error occurs

 $Arguments:	book, to be updated
                entry, to update
                currentStatus, pointer to status word
 
*******************************************************************************/

static UBYTE changeName( UBYTE book, T_MFW_PHB_ENTRY *entry, T_MFW_PHB_STATUS *currentStatus )
{
	TRACE_FUNCTION( "changeName()" );

	if ( book == PHB_SDN )
		return MFW_PHB_FAIL;

	return phb_store_entry( book, entry, currentStatus );
}







/*******************************************************************************

 $Function:    	deleteName

 $Description:	Delete a phone book entry
 
 $Returns:		status of delete, or MWB_PHB_FAIL if an error occurs

 $Arguments:	book, to be updated
                index, index of entry to delete
                currentStatus, pointer to status word
 
*******************************************************************************/

static UBYTE deleteName( UBYTE book, UBYTE index, T_MFW_PHB_STATUS *currentStatus )
{
	TRACE_FUNCTION( "deleteName()" );

	if (  book == PHB_SDN )
		return MFW_PHB_FAIL;

	return phb_delete_entry( book, index, currentStatus );
}










/*******************************************************************************

 $Function:    	addName

 $Description:	Add a new name to the phone book
 
 $Returns:		status of change, or MWB_PHB_FAIL if an error occurs

 $Arguments:	book, to be updated
                entry, to update
                currentStatus, pointer to status word
 
*******************************************************************************/

static UBYTE addName( UBYTE book, T_MFW_PHB_ENTRY *entry, T_MFW_PHB_STATUS *currentStatus )
{
	TRACE_FUNCTION( "addName()" );

  //MC-- Commented out UPN-specific code as it causes the name string in a UPN
  //entry to be stored incorrectly and doesn't seem to be neccessary.
  //Generic code here seems to work fine for UPN
    {
        /* normal store operation
        */
	{
		char temp[120];
		memset(temp,'\0',100);
#ifdef NO_ASCIIZ
{
	T_MFW_PHB_TEXT buf;

		/*SPR 1752 check for unicode*/
	   	if (entry->name.data[0] ==0x80)
		{
			/*MC, don't do any conversions!!*/
			TRACE_EVENT("Converting Unicode 2 SIM");

			sprintf(temp,"Book: %d Name %s Number %s",
				book,
				(char*)buf.data,(char*)entry->number);

		}
		else
		
		{
			// convert from GSM to Alpha characters
			bookGsm2Alpha( (UBYTE *) entry->name.data );

			sprintf(temp,"Book: %d Name %s Number %s",
				book,
				(char*)entry->name.data,(char*)entry->number);
		}
}
#else
		sprintf(temp,"Book: %d Name %s Number %s",
				book,
			(char*)entry->name,(char*)entry->number);
#endif
		TRACE_EVENT(temp);
	}
	    entry->index = 0;
        return phb_store_entry( book, entry, currentStatus );
    }
}








/*******************************************************************************
                                                                              
                          File Handling Utilities
                                                                              
*******************************************************************************/

/*******************************************************************************

 $Function:    	storeInFile

 $Description:	Converts the name to a storeable format and stores it
                in the phone book
 
 $Returns:		None

 $Arguments:	phbk, pointer to phonebook structure
 
*******************************************************************************/

void storeInFile( T_phbk *phbk )
{	int i;
	UBYTE actual_length;
	char debug[20];
	TRACE_FUNCTION( "storeInFile()" );

    /* Convert the name
    */
#ifdef NO_ASCIIZ

    /* if the pattern is GSM default format, use the function mfw_Gsm2SIMStr() here
    */


    if (phbk->edt_buf_name[0] == 0x80)//if unicode
    {
   		 for (i =0; i < PHB_MAX_LEN; i+=2) //work out string length
   	 	{	if (phbk->edt_buf_name[i] == 0 && phbk->edt_buf_name[i+1] == 0)
   			{	if (i== 0)
   					actual_length =0;
   				else
   					actual_length = i -2;
    			break;
    		}
    	}
    	phbk->edt_buf_name[0] = (UBYTE)(actual_length/2);//add string length to beginning of string
    	phbk->edt_buf_name[1] = 0x00;
    /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN*/
    memset(phbk->newEntry.name.data, 0,MAX_ALPHA_LEN);
    //convert to SIM string

	mfw_Ucs2SIMStr( MFW_DCS_UCS2 , (U16*)phbk->edt_buf_name, MAX_ALPHA_LEN,
	
        phbk->newEntry.name.data, &phbk->newEntry.name.len );
	TRACE_EVENT(	(char*)phbk->newEntry.name.data);
	sprintf(debug, "length:%d", phbk->newEntry.name.len);
	TRACE_EVENT(debug);
    }
    else
    {
    	mfw_Gsm2SIMStr( MFW_DCS_7bits, (U16*)phbk->edt_buf_name, MAX_ALPHA_LEN,
        phbk->newEntry.name.data, &phbk->newEntry.name.len );	
    }
   
#else
/*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN*/
    strncpy( (char *)phbk->newEntry.name, (char *)phbk->edt_buf_name, MAX_ALPHA_LEN );

#endif

    /* update the number
    */
    strncpy( (char *) phbk->newEntry.number, (char *) phbk->edt_buf_number, PHB_MAX_LEN );
	/*SPR 1327, copy current phonebook type to new entry*/
	phbk->newEntry.book = phbk->current.status.book; 
	/*If current phonebook UPN, don't overwrite phonebook type*/
	if( phbk->newEntry.book !=UPN)
		phbk->newEntry.book = bookActiveBook(WRITE);
    phbk->newEntry.index = 0;

    /* Add the name/number combination to the phone book and setup
       the current text status string
    */
    switch ( addName( phbk->newEntry.book, &phbk->newEntry, &phbk->current.status ) )
    {
        case MFW_PHB_OK :
        {
            /* Entry saved okay
            */
            MmiBookSetCurrentText( TxtSaved  );
        }
        break;

        case MFW_PHB_FULL :
        {
            /* Phone book full
            */
            MmiBookSetCurrentText( TxtPhbkFull  );
        }
        break;

        case MFW_PHB_FAIL :
        {
            /* Write failure
            */
            MmiBookSetCurrentText( TxtWriteError  );
        }
        break;

		default:
        {
            /* No other returns possible
            */
        }
        break;
    }
}







/*******************************************************************************

 $Function:    	changeInFile

 $Description:	change the phone book entry
 
 $Returns:		none

 $Arguments:	phbk, pointer to phonebook structure
 
*******************************************************************************/

void changeInFile( T_phbk *phbk )
{	int i;
	int actual_length;
	TRACE_FUNCTION( "changeInFile()" );

	if(phbk->current.status.book == PHB_ADN_FDN)
		phbk->current.status.book = PHB_ADN;	//JVJE We can only store in ADN/FDN 
	else
		phbk->current.status.book = phbk->current.status.book;
	
	TRACE_EVENT_P1("Current Book = %d", phbk->current.status.book);
	TRACE_EVENT_P1("Current Name = %s",  phbk->current.selectedName);
	TRACE_EVENT_P1("Current Buf Name = %s", phbk->edt_buf_name);


    /* Convert the name
    */
#ifdef NO_ASCIIZ
	/*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
    if (phbk->edt_buf_name[0] == 0x80)//if unicode
    {
   		 for (i =0; i < MAX_ALPHA_LEN; i+=2) //work out string length
   	 	{	if (phbk->edt_buf_name[i] == 0 && phbk->edt_buf_name[i+1] == 0)
   			{	if (i== 0)
   					actual_length =0;
   				else
   					actual_length = i -2;
    			break;
    		}
    	}
    	phbk->edt_buf_name[0] = (UBYTE)(actual_length/2);//add string length to beginning of string
    	phbk->edt_buf_name[1] = 0x00;
    
      memset(phbk->current.entry[phbk->current.selectedName].name.data, 0, MAX_ALPHA_LEN);
    //convert to SIM string
	mfw_Ucs2SIMStr( MFW_DCS_UCS2, phbk->edt_buf_name, MAX_ALPHA_LEN,
        phbk->current.entry[phbk->current.selectedName].name.data,
        &phbk->current.entry[phbk->current.selectedName].name.len );
    }
else
    {	mfw_Gsm2SIMStr( MFW_DCS_7bits, (U16*)phbk->edt_buf_name, MAX_ALPHA_LEN,
        phbk->current.entry[phbk->current.selectedName].name.data, &phbk->current.entry[phbk->current.selectedName].name.len );
	}
#else

    strncpy( (char *) phbk->current.entry[ phbk->current.selectedName ].name,
        (char *) phbk->edt_buf_name, MAX_ALPHA_LEN );

#endif


/* update the number
    */
    strncpy( (char *) phbk->current.entry[ phbk->current.selectedName ].number,
        (char *) phbk->edt_buf_number, PHB_MAX_LEN );

    /* Add the name/number combination to the phone book and setup
       the current text status string
    */
    switch ( changeName( phbk->current.status.book,
        &phbk->current.entry[ phbk->current.selectedName ], &phbk->current.status ) )
    {
        case MFW_PHB_OK :
        {
            /* Entry saved okay
            */
            MmiBookSetCurrentText( TxtSaved  );
        }
        break;

        case MFW_PHB_FAIL :
        {
            /* Write failure
            */
            MmiBookSetCurrentText(  TxtWriteError );
        }
        break;

		default:
        {
            /* No other returns possible
            */
        }
        break;
    }

    /* SPR881 - SH - Need to update list, because order may have changed
       due to alphabetic sorting.
    */
	if ( phbk->search_win )
    {
        /* perform the search
        */
		SEND_EVENT( phbk->search_win, SEARCH_STRING, 0, 0 );
	}
}









/*******************************************************************************

 $Function:    	deleteFromFile

 $Description:	delete an entry from a phone book
 
 $Returns:		None

 $Arguments:	phbk, phone book handle,
                book, book to update,
 
*******************************************************************************/

⌨️ 快捷键说明

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