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

📄 mmibookutils.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 5 页
字号:
                currentStatus->used_entries,
                currentStatus->avail_entries);
        TRACE_EVENT(temp);
    }
    return temp;
}

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

 $Function:    	bookFindNames

 $Description:	Fine name in phone book
 
 $Returns:		status of search

 $Arguments:	number, number of entries to search, current,
                pointer to structure containing search context
 
*******************************************************************************/

UBYTE bookFindName( UBYTE number, tMmiPhbData *current )
{
    UBYTE   ret;
    int     index, Count = 0;
    UBYTE   l_name[PHB_name_len];

    UBYTE   book_type, index_type;

    int i;
    char debug[22];
    char temp2[50];

    TRACE_EVENT( "bookFindName()" );

    /* Firstly, check for an empty book
    */
    bookGetCurrentStatus( &current->status );
    if ( current->status.used_entries < 1 )
    {
        current->index = 0;
        return MFW_PHB_OK;
    }

    /* Okay, we have some entries to search, so initialise the current
       entry buffer to empty
    */
    memset( current->entry, 0, MAX_SEARCH_CALL_LIST * sizeof( T_MFW_PHB_ENTRY ) );



    current->list.entry         = current->entry;
    current->list.num_entries   = number;

    /* Sort out how we index the information
    */
    book_type  = current->status.book;
    index_type = MFW_PHB_INDEX;


    if ( ( book_type == bookActiveBook(WRITE) ) || ( book_type == PHB_SDN ) )
        index_type = MFW_PHB_ALPHA;

    /* Sort out the type of search we are performing
    */
    if ( (book_type == PHB_LDN) || (book_type == PHB_LRN)|| (book_type == PHB_LMN) )
        index_type = MFW_PHB_INDEX;
    else
    {
        if ( current->KindOfSearch == SEARCH_BY_NAME )
            index_type = MFW_PHB_ALPHA;
        else if ( current->KindOfSearch == SEARCH_BY_NUMBER )
            index_type = MFW_PHB_NUMBER;
        else if ( current->KindOfSearch == SEARCH_BY_LOCATION )
            index_type = MFW_PHB_INDEX;
    }


    /* read the appropriate entries from the phone book
    */
    {
        char temp[255];
        sprintf(temp,"book %d index %d indextype %d number %d",
                book_type,current->index,index_type,number);
        TRACE_EVENT(temp);      
    }   

    if ( book_type == PHB_ADN )   /*Quick test */
    {
        TRACE_EVENT("book_type == PHB_ADN");
        ret = phb_read_entries( PHB_ADN_FDN, current->index, index_type, number, &current->list );
    }
    else
    {
        TRACE_EVENT("book_type == OTHER");
        ret = phb_read_entries( book_type, current->index, index_type, number, &current->list );
    }

    /* Populate the output structures
    */
    if ( current->list.result == MFW_NO_ENTRY )
        current->index = 0;

    for ( index = 0; index < number; index++ )
#ifdef NO_ASCIIZ
    {
#ifdef EASY_TEXT_ENABLED

        int actual_length;

        /* GSM character sets
        */
        TRACE_EVENT( (char*)current->entry[index].name.data);
        TRACE_EVENT("Convert from SIM to UCS2");

        //mfw_SIM2UcsStr( /*current->entry[index].name.len*/PHB_name_len, 
        //   current->entry[index].name.data, PHB_name_len, (U16*)l_name );
        if ( current->entry[index].name.data[0] == 0x80 )
        {
            for ( i=1; i<PHB_name_len; i+=1 )
            {
                l_name[i+1] = current->entry[index].name.data[i];
                //l_name[i] = current->entry[index].name.data[i+1];
            }
            l_name[0] = current->entry[index].name.data[0]; 
            l_name[1] = PHB_name_len;

            memcpy( current->entry[index].name.data, (char*)l_name, PHB_name_len );

            for ( i=0; i < PHB_name_len;i++ )
            {
                if ( current->entry[index].name.data[i]== 0 && current->entry[index].name.data[i+1] != 0 )
                    debug[i] = '0';
                else
                    debug[i] = (char)current->entry[index].name.data[i];
            }

            for ( i =0; i < PHB_name_len; i+=2 ) //work out string length
            {
                if ( current->entry[index].name.data[i] == 0 && current->entry[index].name.data[i+1] == 0 )
                {
                    if ( i== 0 )
                        actual_length =0;
                    else
                        actual_length = i -2;
                    break;
                }
            }
            current->entry[index].name.len = actual_length;


        }

        else
#endif
            bookGsm2Alpha( (UBYTE *) current->entry[index].name.data ); 
    }
#else
    {
        bookGsm2Alpha( (UBYTE *) current->entry[index].name );
    }
#endif

    /* Needed to make international calls from the phonebook
    */
    for ( index = 0; index < number; index++ )
    {
        if ( current->entry[index].ton )
        {
            /* Pre-pend a '+' to the phone number string because
               this number is international
            */
            memmove( (char *) &current->entry[ index ].number[ 1 ],
                     (char *) current->entry[ index ].number, PHB_number_len - 1 );

            /* Now pre-pend the '+'
            */
            current->entry[index].number[0] = '+';
        }
    }
    TRACE_EVENT("Book searched");   
    return current->result = ret;
}
/*******************************************************************************

 $Function:    	bookEvent

 $Description:	Event handler for a phone book event
 
 $Returns:		MFW_EVENT_CONSUMED if recognised message, otherwise
                MFW_EVENT_PASSED

 $Arguments:	e, event, para, general parameter giving context of call
 
*******************************************************************************/

int bookEvent( MfwEvt e, void *para )
{
    T_MFW_PHB_STATUS *status;

    T_MFW_PHB_ENTRY    l_phb_Shortentry;
    T_MFW_PHB_STATUS   newstatus; 
    int                  Index,i;

    char                 temp[100];

    TRACE_FUNCTION( "bookEvent" );

    /* deal with the incoming event
    */
    switch ( e )
    {
    case E_PHB_UPN_LIST :
        {
            upnList = (T_MFW_UPN_LIST *)para;
        }
        break;

    case E_PHB_STATUS:
        {
            status = (T_MFW_PHB_STATUS *)para;
            if ( ( status->book == PHB_FDN ) || ( status->book == PHB_ADN ) )
            {
                if ( pinsSetIsFocussed() == FOCUSSED_PINS )
                    backpinFDNactdeact();
            }
        }
        break;
    case E_PHB_ERROR:
        {
            /* tbd */
            //hxl add 20020917--------------------------------------
            MmiTrace("E_PHB_ERROR");
            if ( PcCmdStatus.isPcCmdRun )
            {
                PcCmdStatus.isPcCmdRun=0;
                MmiTrace("write_sim_phb_cb");
                write_sim_phb_cb();
                return MFW_EVENT_CONSUMED;
            }
            //end of hxl add 20020917------------------------------------
        }
        break;

    case E_PHB_READY:
        {
            TRACE_EVENT("Entry bookevent");
            MmiTrace("E_PHB_READY");
            //hxl add 20020917--------------------------------------
            if ( PcCmdStatus.isPcCmdRun )
            {
                PcCmdStatus.isPcCmdRun=0;
                MmiTrace("write_sim_phb_cb");
                write_sim_phb_cb();
                return MFW_EVENT_CONSUMED;
            }
            //end of hxl add 20020917------------------------------------

            if ( phonebookstatus==COPYINGALL )
            {
                sprintf(temp,"Copyidx:%d",Copyidx);
                TRACE_EVENT(temp);
                if ( CopyNumber==NVMTotal )
                {
                    GetSIMData();
                    Create_SORT_Table(l_phb_index,ALL_NUMBER_LIST );    
                    CopyResult.CopyEnd=TRUE;
                    CopyResult.complete=MFW_PHB_OK;
                    phonebookstatus=COPYNONE;
                }
                else if ( Copyidx==PHBKTotal )
                {
                    GetSIMData();
                    Create_SORT_Table(l_phb_index,ALL_NUMBER_LIST );    
                    CopyResult.CopyEnd=TRUE;
                    CopyResult.complete=MFW_PHB_FAIL;
                    phonebookstatus=COPYNONE;
                }
                else
                {
                    TRACE_EVENT("copy not finished!");
                    for ( i=Copyidx;i<PHBKTotal;i++ )
                    {
                        if ( l_phb_index[l_phb_sort_index[i].index].phonebook==NVM_BOOK_SEL )
                        {
                            Index=l_phb_sort_index[i].index;

                            if ( CurrentTable!=Index/PHB_table_len )
                            {
                                if ( flash_PBread(PBTable[Index/PHB_table_len])!=0 )
                                    CurrentTable=Index/PHB_table_len;
                            }

                            memset(&l_phb_Shortentry,0,sizeof(l_phb_Shortentry));
                            l_phb_Shortentry.book=bookActiveBook(WRITE);
                            newstatus.book=l_phb_Shortentry.book;

                            memcpy(l_phb_Shortentry.name.data,FFS_PBData.NVMBook[Index%PHB_table_len].name,PHB_name_len);
                            l_phb_Shortentry.name.len=wstrlen((char *)l_phb_Shortentry.name.data);
                            //================================================================================================                      
                            switch ( CheckFirstNumFlag(Index) )
                            {
                            case 0x01:
                                if ( wstrlen((char *)FFS_PBData.NVMBook[Index%PHB_table_len].number)!=0 )
                                    UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].number,l_phb_Shortentry.number);
                                else if ( wstrlen((char *)FFS_PBData.NVMBook[Index%PHB_table_len].home)!=0 )
                                    UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].home,l_phb_Shortentry.number);
                                else if ( wstrlen((char *)FFS_PBData.NVMBook[Index%PHB_table_len].office)!=0 )
                                    UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].office,l_phb_Shortentry.number);
                                break;  
                            case 0x02:
                                if ( wstrlen((char *)FFS_PBData.NVMBook[Index%PHB_table_len].home)!=0 )
                                    UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].home,l_phb_Shortentry.number);
                                else if ( wstrlen((char *)FFS_PBData.NVMBook[Index%PHB_table_len].number)!=0 )
                                    UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].number,l_phb_Shortentry.number);
                                else if ( wstrlen((char *)FFS_PBData.NVMBook[Index%PHB_table_len].office)!=0 )
                                    UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].office,l_phb_Shortentry.number);
                                break;
                            case 0x03:
                                if ( wstrlen((char *)FFS_PBData.NVMBook[Index%PHB_table_len].office)!=0 )
                                    UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].office,l_phb_Shortentry.number);
                                else if ( wstrlen((char *)FFS_PBData.NVMBook[Index%PHB_table_len].number)!=0 )
                                    UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].number,l_phb_Shortentry.number);
                                else if ( wstrlen((char *)FFS_PBData.NVMBook[Index%PHB_table_len].home)!=0 )
                                    UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].home,l_phb_Shortentry.number);
                                break;
                                //================================================================================================                                  
                            }
                            //UnCompressNum((char *)FFS_PBData.NVMBook[Index%PHB_table_len].number,l_phb_Shortentry.number);                                                                      

                            switch ( addName(l_phb_Shortentry.book,&l_phb_Shortentry,&newstatus) )
                            {
                            case MFW_PHB_OK :
                                {
                                    TRACE_EVENT("OK");
                                    CopyResult.CopyEnd=FALSE;
                                    CopyResult.complete=MFW_PHB_OK;                                                                       
                                }
                                break;
                            case MFW_PHB_FULL :
                                {
                                    // Phone book full
                                    TRACE_EVENT("full");
                                    GetSIMData();
                                    Create_SORT_Table(l_phb_index,ALL_NUMBER_LIST );    
                                    CopyResult.CopyEnd=TRUE;
                                    CopyResult.complete=MFW_PHB_FULL;
                                    phonebookstatus=COPYNONE;                                                               
                                }
                                break;
                            case MFW_PHB_FAIL :
                            default:    
                                {
                                    TRACE_EVENT("faile or out");
                                    GetSIMData();
                                    Create_SORT_Table(l_phb_index,ALL_NUMBER_LIST );
                                    CopyResult.CopyEnd=TRUE;
                                    CopyResult.complete=MFW_PHB_FAIL;

⌨️ 快捷键说明

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