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

📄 mmisatinput.c

📁 是一个手机功能的模拟程序
💻 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                                                            
 $Module:		SMS
 $File:		    mmiSatInput.c
 $Revision:		1.0                                                       
                                                                              
 $Author:		Condat(UK)                                                         
 $Date:		    25/10/00                                                      
                                                                               
********************************************************************************
                                                                              
 Description:
 
    Implementation of MMI SIM Application Toolkit (SAT)
                        
********************************************************************************

 $History: mmiSatInput.c

    25/10/00			Original Condat(UK) BMI version.	
    16/08/02            verion0.100 zhaowm modified
       
 $End

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

#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_edt.h"
#include "mfw_lng.h"
#include "mfw_icn.h"
#include "mfw_phb.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_sms.h"
#include "mfw_mnu.h"
#include "mfw_sat.h"
#include "mfw_tim.h"
#include "mfw_ss.h"
#include "mfw_str.h"

#include "dspl.h"

#include "MmiMmi.h"
#include "MmiDummy.h"
#include "MmiDialogs.h"
#include "MmiLists.h"

#include "MmiMain.h"
#include "MmiStart.h"
#include "MmiPins.h"
#include "MmiMenu.h"
#include "MmiSoftKeys.h"
#include "MmiSounds.h"
#include "MmiCall.h"

#include "mmiSat_i.h"
#include "mmiEditor.h"
#include "psa_util.h"

#include "cus_aci.h"
#include "p_sim.h"
#include "pcm.h"
#include "mmiusersymbolinput.h"

/* 2004/04/12 sunsj add */
#include "mmitextinput.h"

//#define TDTRACE 1
#include "mmiutilapi.h"

static void sat_editor_cb (T_MFW_HND win, USHORT Identifier, USHORT event);

/*********************************************************************
 *
 * SUB WINDOW  SAT_GET_KEY
 *
 *********************************************************************/
#define SAT_GET_KEY_BUFFER_SIZE (UBYTE)(1+2+2) /* two spares for mfwEdt *///zhaowm 2002/08/05

typedef struct
{
    T_MMI_CONTROL  mmi_control;
    T_MFW_HND      win;
    T_SAT_CMD     *sat_command; /* pointer to sat_command in parent */
    T_EDITOR_DATA  editor_data;
    char          *edt_buffer; /* buffer for editor */ 
    // T_MFW_HND     key_editor;//zhaowm2002/7/30 to be destroy editor_win
    T_MFW_HND      kbd;  /* sbh - keyboard handler, so window can be destroyed by user */
} T_sat_get_key;

static void sat_get_key_destroy (T_MFW_HND own_window);
static void sat_get_key_exec (T_MFW_HND win, USHORT event, SHORT value, T_SAT_CMD * sat_command);

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

 $Function:    	sat_get_key_create

 $Description:	Creation of an instance for the SAT GET KEY dialog.Window must 
                be available after reception of SAT command,only one instance.

 
 $Returns:		mfw window handler 

 $Arguments:	parent_window - Parent window handler
 
*******************************************************************************/

T_MFW_HND sat_get_key_create (T_MFW_HND parent_window)
{
    T_sat_get_key * data = (T_sat_get_key *)ALLOC_MEMORY (sizeof (T_sat_get_key));
    T_MFW_WIN     * win;

    data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)sat_win_cb); // c030 rsa

    if( data->win EQ NULL )
        return NULL;

    /*
     * Create window handler
     */
    data->mmi_control.dialog   = (T_DIALOG_FUNC)sat_get_key_exec;
    data->mmi_control.data     = data;
    win                        = ((T_MFW_HDR *)data->win)->data;
    win->user                  = (MfwUserDataPtr)data;

    data->kbd      = kbdCreate( data->win, KEY_ALL, (T_MFW_CB) sat_kbd_cb); /* sbh - add keyboard handler */

    /*
     * return window handle
     */
    win_show(data->win);
    return data->win;
}

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

 $Function:    	sat_get_key_destroy

 $Description:	Destroy the sat get inkey dialog.

 
 $Returns:		none

 $Arguments:	own_window - window handler
 
*******************************************************************************/

static void sat_get_key_destroy (T_MFW_HND own_window)
{
    T_MFW_WIN * win_data   = ((T_MFW_HDR *)own_window)->data;
    T_sat_get_key * data = (T_sat_get_key *)win_data->user;

    if( data )
    {
        /*
         * Delete WIN Handler
         */
        win_delete (data->win);
        /*
         * Free Memory
         */
        FREE_MEMORY ((U8 *)data->edt_buffer,
                     SAT_GET_KEY_BUFFER_SIZE * sizeof(char));
        sat_destroy_TEXT_ASCIIZ (data->editor_data.TextString); /* label */
        FREE_MEMORY ((U8 *)data, sizeof (T_sat_get_key));
    }
}

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

 $Function:    	sat_get_key_exec

 $Description:	Dialog function for sat_get_key_exec window.

 
 $Returns:		none

 $Arguments:	win - window handler
                event -window event
                value - unique id
                sat_command - Sat command info
 
*******************************************************************************/

static void sat_get_key_exec (T_MFW_HND win, USHORT event, SHORT value, T_SAT_CMD * sat_command)
{
    T_MFW_WIN       * win_data   = ((T_MFW_HDR *)win)->data;
    T_sat_get_key   * data       = (T_sat_get_key *)win_data->user;

    T_SAT_TXT       * txt;
    T_SAT_RES sat_res;

    TRACE_FUNCTION ("sat_get_key_exec()");

    switch( event )
    {
    case SAT_GET_KEY:
        data->sat_command = sat_command; /* save a pointer to the parameter for later use in callbacks */
        txt = (T_SAT_TXT *)&sat_command->c.text;

        /* allocate a buffer to hold the edited chars */
        data->edt_buffer = (char *)ALLOC_MEMORY (
                                                SAT_GET_KEY_BUFFER_SIZE * sizeof(char));

        /*
         * Setup an Editor to get a single key 
         */
        if( (sat_command->qual & SAT_M_INKEY_HELP_AVAIL) NEQ 0 )
        {
            data->editor_data.AlternateLeftSoftKey  = TxtHelp; /* help available */
        }
        else
        {
            data->editor_data.AlternateLeftSoftKey  = TxtNull; /* no help available */
        }
        if( (sat_command->qual & SAT_M_INKEY_YES_NO) NEQ 0 )
        {
            /* yes/no decision */
            data->editor_data.LeftSoftKey    = TxtYes;
            data->editor_data.RightSoftKey   = TxtNo;
            data->editor_data.mode           = ONLYREAD_MODE;//E_EDIT_READ_ONLY_MODE; /* treat as read-only, thus ignoring normal keys */
        }
        else
        {
            /* normal single key request */
            data->editor_data.LeftSoftKey    = TxtSoftOK;
            data->editor_data.RightSoftKey   = TxtDelete;//TxtSoftBack;  //zhaowm 2003.0416
            if( (sat_command->qual & SAT_M_INKEY_ALPHA) EQ 0 ) /* 0=digits, 1=alpha */
            {
                data->editor_data.mode = PHONENUMONLY_MODE;
                ;
            }
            else
            {
                //data->editor_data.mode = E_EDIT_ALPHA_MODE;
                data->editor_data.mode = TEXTINPUT_MODE; /* 2003/12/04 sunsj modify */
				data->editor_data.InputMode = PINYIN_INPUT_MODE;	/* 2004/04/12 sunsj add */
            }
        }
        data->editor_data.TextId                 = TxtNull;
        if( txt->len > 0 )
        {
            data->editor_data.TextString     = sat_create_TEXT_ASCIIZ (txt); /* label */
        }
        else
        {
            data->editor_data.TextString     =  NULL; /* no label */
        }
        data->editor_data.min_enter              = 0; /* get a single key */
        data->editor_data.timeout                = TWENTY_SECS; 
        data->editor_data.Identifier             = event;
        if( (sat_command->qual & SAT_M_INKEY_HELP_AVAIL) NEQ 0 )
        {
            data->editor_data.AlternateLeftSoftKey  = TxtHelp; /* help available */
        }
        else
        {
            data->editor_data.AlternateLeftSoftKey  = 0;       /* no help available */
        }
        data->editor_data.hide                   = FALSE; 


        /* provide an empty zero terminated buffer */
        data->edt_buffer[0] = '\0'; 

        /*
         * Start the Editor
         */
        //        data->key_editor=editor_start_common (win, data->edt_buffer, 3, &data->editor_data, (T_EDIT_CB)sat_editor_cb);//zhaowm2002/7/30
        //        if (data->key_editor== NULL)            
        if( editor_start_common (win, data->edt_buffer, 3, &data->editor_data, (T_EDIT_CB)sat_editor_cb) == NULL )
        {
            sat_res[SAT_ERR_INDEX] = SAT_RES_IMPOSSIBLE;
            sat_res[SAT_AI_INDEX]  = SatResAiNoCause;
            sat_done (sat_command, sat_res, sizeof(T_SAT_RES));
            sat_get_key_destroy (data->win);
        }
        break;

        /* sbh - all window types are being provided with this event to destroy the window */
    case SAT_DESTROY_WINDOW:
        sat_get_key_destroy (data->win);
        break;
        /* ...sbh */

    default:
        TRACE_EVENT ("sim_get_key_exec() unexpected event");
        break;
    }
}

/*********************************************************************
 *
 * SUB WINDOW  SAT_GET_STRING
 *
 *********************************************************************/
#define SAT_GET_STRING_BUFFER_SIZE (UBYTE)255
typedef struct
{
    T_MMI_CONTROL  mmi_control;
    T_MFW_HND      win;
    T_SAT_CMD     *sat_command; /* pointer to sat_command in parent */
    T_EDITOR_DATA  editor_data;
    char          *edt_buffer; /* buffer for editor */ 
    //  T_MFW_HND     string_editor;//zhaowm2002/7/30 to be destroy editor_win
    U16            max_chars;
    T_MFW_HND       kbd;  /* sbh - keyboard handler, so window can be destroyed by user */
} T_sat_get_string;

typedef struct
{
    T_SAT_TXT txt;
    UBYTE     buffer[1]; /* open array */ 
} T_sat_get_string_result; /* NOTE: txt and buffer shall be packed */

static void sat_get_string_destroy (T_MFW_HND own_window);
static void sat_get_string_exec (T_MFW_HND win, USHORT event, SHORT value, T_SAT_CMD * sat_command);

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

 $Function:    	sat_get_string_create

 $Description:	Creation of an instance for the SAT GET STRING dialog.Window must 
                be available after reception of SAT command,only one instance.

 
 $Returns:		window 

 $Arguments:	parent_window - parent window
*******************************************************************************/
T_MFW_HND sat_get_string_create (T_MFW_HND parent_window)
{
    T_sat_get_string * data = (T_sat_get_string *)ALLOC_MEMORY (sizeof (T_sat_get_string));
    T_MFW_WIN        * win;

    data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)sat_win_cb);  // c030 rsa

    if( data->win EQ NULL )
        return NULL;

    /*
     * Create window handler
     */
    data->mmi_control.dialog   = (T_DIALOG_FUNC)sat_get_string_exec;
    data->mmi_control.data     = data;

⌨️ 快捷键说明

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