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

📄 mfw_phb.c

📁 GSM手机设计软件代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417)         $Workfile:: mfw_phb.c       $|
| $Author:: Vo                          $Revision::  1              $|
| CREATED: 7.1.99                       $Modtime:: 12.01.00 11:19   $|
| STATE  : code                                                      |
+--------------------------------------------------------------------+

   MODULE  : MFW_PHB

   PURPOSE : This modul contains phonebook management functions.

*/

#define ENTITY_MFW

#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_mfw.h"
#include "mfw_phb.h"
#include "mfw_phbi.h"
#include "mfw_cm.h"
#include "mfw_cmi.h"

#include "mfw_nm.h"
#include "mfw_sim.h"
#include "mfw_sima.h"
#include "mfw_nmi.h"
#include "mfw_simi.h"
#include "mfw_sms.h"
#include "mfw_smsi.h"
#include "mfw_win.h"

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

#if defined (FAX_AND_DATA)
#include "aci_fd.h"
#endif

#include "message.h"
#include "prim.h"
#include "aci_cmh.h"

#include "cmh.h"
#include "phb.h"
#include "cmh_phb.h"

#include "mfw_ss.h"
#include "mfw_ssi.h"
#include "mfw_win.h"

#include "gdi.h"
#include "pcm.h"

/* SPR#1112 - SH - Required for internal phonebook */
#ifdef INT_PHONEBOOK
#include "ATBPbGI.h"
#endif
    

/********* current define *******************************************/
static T_ACI_PB_ENTR   pb_list[PHB_MAX_ENTRY_NUM];
static T_MFW_UPN_LIST  upn_list;
static UBYTE cnt;     /* count of user personal numbers */

EXTERN MfwHdr * current_mfw_elem;

/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417)         MODULE: MFW_PHB              |
| STATE  : code                         ROUTINE: phb_create          |
+--------------------------------------------------------------------+


   PURPOSE :  create event for phonebook management

*/

T_MFW_HND phb_create(T_MFW_HND hWin, T_MFW_EVENT event, T_MFW_CB cbfunc)
{
  T_MFW_HDR *hdr;
  T_MFW_PHB  *phb_para;
  MfwHdr *insert_status =0;
  
  TRACE_FUNCTION ("phb_create()");

  hdr      = (T_MFW_HDR *) mfwAlloc(sizeof (T_MFW_HDR));
  phb_para  = (T_MFW_PHB *) mfwAlloc(sizeof (T_MFW_PHB));

  if (!hdr OR !phb_para)
  	{
    	TRACE_ERROR("ERROR: phb_create() Mem Alloc Failed.");
			
	   	if(hdr)
   			mfwFree((U8*)hdr,sizeof(MfwHdr));
   		if(phb_para)
   			mfwFree((U8*)phb_para,sizeof(T_MFW_PHB));	
   		
	   	return FALSE;
  	}

  /*
   * initialisation of the handler
   */
  phb_para->emask   = event;
  phb_para->handler = cbfunc;

  hdr->data = phb_para;                           /* store parameter in node     */
  hdr->type = MFW_TYP_PHB;                        /* store type of event handler */

  /*
   * installation of the handler
   */
  insert_status = mfwInsert((T_MFW_HDR *)hWin, hdr);
  if(!insert_status)
	{
  		TRACE_ERROR("ERROR: phb_create() Failed to Install Handler. ");
   		mfwFree((U8*)hdr,sizeof(MfwHdr));
   		mfwFree((U8*)phb_para ,sizeof(T_MFW_PHB));
		return 0;
  	}
  return insert_status;
}


/*
+---------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417)         MODULE: MFW_PHB               |
| STATE  : code                         ROUTINE: phb_delete           |
+---------------------------------------------------------------------+


   PURPOSE :   delete a event for phonebook management

*/

T_MFW_RES phb_delete(T_MFW_HND h)
{
  TRACE_FUNCTION ("phb_delete()");
  
  if (!h OR !((T_MFW_HDR *)h)->data)
    return MFW_RES_ILL_HND;

  if (!mfwRemove((T_MFW_HDR *)h))
    return MFW_RES_ILL_HND;

  mfwFree((U8 *)(((T_MFW_HDR *) h)->data),sizeof(T_MFW_PHB));
  mfwFree((U8 *)h,sizeof(T_MFW_HDR));

  return MFW_RES_OK;
}


/*
+---------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417)         MODULE: MFW_PHB               |
| STATE  : code                         ROUTINE: phb_signal           |
+---------------------------------------------------------------------+

   PURPOSE : send a event signal.

*/

void phb_signal(T_MFW_EVENT event, void * para)
{/*MC, SPR 1389, we have to enable the display whenever 
	we send an event up to the MMI*/
UBYTE temp = dspl_Enable(0);
	
  TRACE_FUNCTION ("phb_signal()");
if (mfwSignallingMethod EQ 0)
  {
  /*
   * focus is on a window
   */
  if (mfwFocus)
    /*
     * send event to phonebook management
     * handler if available
     */
    if (phb_sign_exec (mfwFocus, event, para))
    { dspl_Enable(temp);/*MC, SPR 1389*/
	        return;
	 }

  /*
   * acutal focussed window is not available
   * or has no phonebook management handler,
   * then search all nodes from the root.
   */
   if (mfwRoot)
     phb_sign_exec (mfwRoot, event, para);
  }
  else
    {
      MfwHdr * h = 0;

      /*
       * Focus set, then start here
       */
      if (mfwFocus)
        h = mfwFocus;
      /*
       * Focus not set, then start root
       */
      if (!h)
        h = mfwRoot;

      /*
       * No elements available, return
       */

      while (h)


      {
        /*
         * Signal consumed, then return
         */
        if (phb_sign_exec (h, event, para))
        { dspl_Enable(temp);/*MC, SPR 1389*/
	        return;
	 	}

        /*
         * All windows tried inclusive root
         */
        if (h == mfwRoot)
        { dspl_Enable(temp);/*MC, SPR 1389*/
	        return;
	 	}

        /*
         * get parent window
         */
        h = mfwParent(mfwParent(h));
		if(h)
			h = ((MfwWin * )(h->data))->elems;
      }
      phb_sign_exec (mfwRoot, event, para);
    }
   dspl_Enable(temp);/*MC, SPR 1389*/

}

/*
+---------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417)         MODULE: MFW_PHB               |
| STATE  : code                         ROUTINE: phb_sign_exec        |
+---------------------------------------------------------------------+


   PURPOSE : Send a signal if PHB management handler.

*/

BOOL phb_sign_exec (T_MFW_HDR * cur_elem, T_MFW_EVENT event, T_MFW_PHB_PARA * para)
{
  TRACE_FUNCTION ("phb_sign_exec()");

  while (cur_elem)
  {
    /*
     * event handler is available
     */
    if (cur_elem->type EQ MFW_TYP_PHB)
    {
      T_MFW_PHB * phb_data;
      /*
       * handler is PHB management handler
       */
      phb_data = (T_MFW_PHB *)cur_elem->data;
      if (phb_data->emask & event)
      {
        /*
         * event is expected by the call back function
         */
        phb_data->event = event;
        switch (event)
        {
          case E_PHB_STATUS:
            memcpy (&phb_data->para.phb_status, para, sizeof (T_MFW_PHB_STATUS));
            break;
          case E_PHB_UPN_LIST:
            memcpy (&phb_data->para.upn_list, para, sizeof (T_MFW_UPN_LIST));
            break;
          /* SPR#1112 - SH - Add these events */
          case E_PHB_READY:
          	break;
          case E_PHB_BUSY:
          	break;
        }

        /*
         * if call back defined, call it
         */
        if (phb_data->handler)
        {
          // PATCH LE 06.06.00
          // store current mfw elem
          current_mfw_elem = cur_elem;
          // END PATCH LE 06.06.00

          if ((*(phb_data->handler)) (phb_data->event, (void *)&phb_data->para))
            return TRUE;
        }
      }
    }
    cur_elem = cur_elem->next;
  }
  return FALSE;
}


/*
+-------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : MFW_PHB                 |
| STATE   : code                  ROUTINE : phb_codePhbType         |
+-------------------------------------------------------------------+

  PURPOSE : This function is used to convert the type of phonebook
            used by MFW to the type of phonebook used by ACI.
*/
LOCAL T_ACI_PB_STOR phb_codePhbType ( T_PHB_TYPE inMem )
{
  switch ( inMem )
  {
    case ( PHB_FDN ): return PB_STOR_Fd;
    case ( PHB_LDN ): return PB_STOR_Ld;
    case ( PHB_ECC ): return PB_STOR_Ed;
    case ( PHB_ADN ): return PB_STOR_Ad;
    case ( PHB_BDN ): return PB_STOR_Bd;
    case ( PHB_LRN ): return PB_STOR_Lr;
    case ( PHB_SDN ): return PB_STOR_Sd;
    case ( PHB_LMN ): return PB_STOR_Lm;
    case ( PHB_ADN_FDN ): return PB_STOR_Af;
    case ( PHB_UPN ): return PB_STOR_Ud;
    default:          return PB_STOR_NotPresent;
  }
}


/*
+-------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : MFW_PHB                 |
| STATE   : code                  ROUTINE : phb_decodePhbType       |
+-------------------------------------------------------------------+

  PURPOSE : This function is used to convert the type of phonebook
            used by MFW to the type of phonebook used by ACI.
*/
LOCAL T_PHB_TYPE phb_decodePhbType ( T_ACI_PB_STOR inMem )
{
  switch ( inMem )
  {
    case ( PB_STOR_Fd ): return PHB_FDN;
    case ( PB_STOR_Ld ): return PHB_LDN;
    case ( PB_STOR_Ed ): return PHB_ECC;
    case ( PB_STOR_Ad ): return PHB_ADN;
    case ( PB_STOR_Bd ): return PHB_BDN;
    case ( PB_STOR_Lr ): return PHB_LRN;
    case ( PB_STOR_Sd ): return PHB_SDN;
    case ( PB_STOR_Lm ): return PHB_LMN;
    case ( PB_STOR_Af ): return PHB_ADN_FDN;
    case ( PB_STOR_Ud ): return PHB_UPN;
    default:          return PHB_NONE;
  }
}


/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417)         MODULE: MFW_PHB              |
| STATE  : code                         ROUTINE: phb_cvtTon          |
+--------------------------------------------------------------------+


   PURPOSE :  This function is used to convert the type of number
              used by ACI to the type of number used by MFW.

*/

T_MFW_PHB_TON phb_cvtTon(T_ACI_TOA_TON ton)
{
    switch (ton)
	{
    case TON_NotPresent:
    case TON_Unknown:           return MFW_TON_UNKNOWN;
    case TON_International:     return MFW_TON_INTERNATIONAL;
    case TON_National:          return MFW_TON_NATIONAL;
    case TON_NetSpecific:       return MFW_TON_NET_SPECIFIC;
    case TON_DedAccess:         return MFW_TON_DED_ACCESS;
    case TON_Alphanumeric:      return MFW_TON_ALPHA_NUMERIC;
    case TON_Abbreviated:       return MFW_TON_ABBREVIATED;
    case TON_Extended:          return MFW_TON_EXTENDED;
		default:					          return ton;
	}
}


/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417)         MODULE: MFW_PHB              |
| STATE  : code                         ROUTINE: phb_ncvtTon         |
+--------------------------------------------------------------------+


   PURPOSE :  This function is used to convert the type of number
              used by MFW to the type of number used by ACI.

*/

T_ACI_TOA_TON phb_ncvtTon(T_MFW_PHB_TON ton)
{
    switch (ton)
	{
		case MFW_TON_INTERNATIONAL:     return TON_International;
		case MFW_TON_NATIONAL:          return TON_National;
    case MFW_TON_NET_SPECIFIC:      return TON_NetSpecific;
    case MFW_TON_DED_ACCESS:        return TON_DedAccess;
    case MFW_TON_ALPHA_NUMERIC:     return TON_Alphanumeric;
    case MFW_TON_ABBREVIATED:       return TON_Abbreviated;
    case MFW_TON_EXTENDED:          return TON_Extended;
		default:					              return TON_Unknown;
	}
}

/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417)         MODULE: MFW_PHB              |
| STATE  : code                         ROUTINE: phb_cvtNpi          |
+--------------------------------------------------------------------+


   PURPOSE :  This function is used to convert the numbering plan
              identifier used by ACI to the numbering plan identifier
              used by MFW.

*/

T_MFW_PHB_TON phb_cvtNpi(T_ACI_TOA_NPI npi)
{
    switch (npi)
	{
    case NPI_NotPresent:
    case NPI_Unknown:       return MFW_NPI_UNKNOWN;
    case NPI_IsdnTelephony: return MFW_NPI_ISDN;
    case NPI_Data:          return MFW_NPI_DATA;
    case NPI_Telex:         return MFW_NPI_TELEX;
    case NPI_Private:       return MFW_NPI_PRIVATE;
    case NPI_National:      return MFW_NPI_NATIONAL;
    case NPI_ERMES:         return MFW_NPI_M_ERMES;
    case NPI_CTS:           return MFW_NPI_M_CTS;
		default:				        return npi;
	}
}


/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417)         MODULE: MFW_PHB              |
| STATE  : code                         ROUTINE: phb_ncvtNpi         |
+--------------------------------------------------------------------+


   PURPOSE :  This function is used to convert the numbering plan
              identifier used by MFW to the numbering plan identifier
              used by ACI.

*/

⌨️ 快捷键说明

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