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

📄 mmisatinput.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 3 页
字号:
    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_string_destroy

 $Description:	Destroy the sat get string dialog.

 
 $Returns:		none

 $Arguments:	own_window - current window.
*******************************************************************************/
static void sat_get_string_destroy (T_MFW_HND own_window)
{
    T_MFW_WIN * win_data    = ((T_MFW_HDR *)own_window)->data;
    T_sat_get_string * data = (T_sat_get_string *)win_data->user;

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

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

 $Function:    	sat_get_string_exec

 $Description:	Dialog function for sat_get_string window.

 
 $Returns:		none

 $Arguments:	win - window handle
                event - window event
                value - unique id
                sat_command - Sat Command info.
*******************************************************************************/
static void sat_get_string_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_string   * data       = (T_sat_get_string *)win_data->user;
    T_SAT_INPUT     * inp;
    T_SAT_TXT      * defRsp;
    T_SAT_RES sat_res;

    TRACE_FUNCTION ("sat_get_string_exec()");

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

        /* allocate a buffer to hold the edited chars */
        data->max_chars = (U16)(inp->rspMax)+1+2;  //zhaowm 2002/08/05
        data->edt_buffer = (char *)ALLOC_MEMORY (
                                                data->max_chars * sizeof(char));

        /*
         * Setup an Editor to get a string 
         */
        data->editor_data.LeftSoftKey            = TxtSoftOK;
        if( (sat_command->qual & SAT_M_INPUT_HELP_AVAIL) NEQ 0 )
        {
            data->editor_data.AlternateLeftSoftKey  = TxtHelp; /* help available */
        }
        else
        {
            data->editor_data.AlternateLeftSoftKey  = TxtNull; /* no help available */
        }
        //data->editor_data.RightSoftKey           = TxtSoftBack;
        data->editor_data.RightSoftKey           = TxtDelete;    //zhaowm 2003.0416

        data->editor_data.hide                   = ((sat_command->qual & SAT_M_INPUT_NOECHO) NEQ 0);
        if( (sat_command->qual & SAT_M_INPUT_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.TextId                 = TxtNull;
        if( inp->prompt.len > 0 )
        {
            data->editor_data.TextString     = sat_create_TEXT_ASCIIZ (&inp->prompt); /* label */
        }
        else
        {
            data->editor_data.TextString     =  NULL; /* no label */
        }
        data->editor_data.min_enter              = inp->rspMin;
        data->editor_data.timeout                = TWENTY_SECS; 
        data->editor_data.Identifier             = event;

        defRsp = &inp->defRsp;
        if( defRsp->len > 0 ) /* default response available? */
        {
            /* provide a zero terminated buffer, initially containing the default response */
            sat_TEXT_to_ASCIIZ (data->edt_buffer, defRsp);
        }
        else
        {
            /* no default response: provide an empty buffer */
            data->edt_buffer[0] = '\0';
        }

        /*
         * Start the Editor
         */
        //     data->string_editor=editor_start_common (win, data->edt_buffer, data->max_chars, &data->editor_data, (T_EDIT_CB)sat_editor_cb);//zhaowm2002/7/30
        //     if (data->string_editor== NULL)
        if( editor_start_common (win, data->edt_buffer, data->max_chars, &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_string_destroy (data->win);
        }
        break;

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

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

/*********************************************************************
 *
 * SUB WINDOW  SAT_DISPLAY_TEXT
 *
 *********************************************************************/
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          *info_buffer; /* buffer for info */ 
    // T_MFW_HND     display_editor;//zhaowm2002/12/05 to be destroy editor_win
    T_MFW_HND       kbd;  /* sbh - keyboard handler, so window can be destroyed by user */
} T_sat_display_text;

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

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

 $Function:    	sat_get_string_exec

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

 $Returns:		Window handle

 $Arguments:	parent_window - parent window
*******************************************************************************/

T_MFW_HND sat_display_text_create (T_MFW_HND parent_window)
{
    T_sat_display_text * data = (T_sat_display_text *)ALLOC_MEMORY (sizeof (T_sat_display_text));
    T_MFW_WIN       * win;

    TRACE_FUNCTION("sat_display_text_create");

    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_display_text_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_display_text_destroy

 $Description:	Destroy the sat play tone dialog.

 $Returns:		none

 $Arguments:	own_window - current window
*******************************************************************************/
static void sat_display_text_destroy (T_MFW_HND own_window)
{
    T_MFW_WIN * win_data   = ((T_MFW_HDR *)own_window)->data;
    T_sat_display_text * data = (T_sat_display_text *)win_data->user;

    TRACE_FUNCTION("sat_display_text_destroy");


    if( data )
    {
        /*
         * Delete WIN Handler
         */
        win_delete (data->win);
        /*
         * Free Memory
         */
        sat_destroy_TEXT_ASCIIZ (data->info_buffer); /* displayed text */
        FREE_MEMORY ((U8 *)data, sizeof (T_sat_display_text));
    }

}

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

 $Function:    	sat_display_text_exec

 $Description:	Dialog function for sat_display_text_exec window.

 $Returns:		none

 $Arguments:	win - window
                event - window event
                value - unique id
                sat_command - sat command data.
*******************************************************************************/

static void sat_display_text_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_display_text * data       = (T_sat_display_text *)win_data->user;
    T_SAT_RES sat_res;

    ULONG             time;

    TRACE_FUNCTION ("sat_display_text_exec()");

    switch( event )
    {
    case SAT_DISPLAY_TEXT:
        data->sat_command = sat_command;

        /*
         * Setup an Editor to display a string 
         */
        data->editor_data.LeftSoftKey            = TxtSoftOK;
        data->editor_data.AlternateLeftSoftKey   = TxtNull; 
        data->editor_data.RightSoftKey           = TxtSoftBack;
        data->editor_data.hide                   = FALSE;
        data->editor_data.mode                   = ONLYREAD_MODE;//E_EDIT_READ_ONLY_MODE; 
        data->editor_data.TextId                 = TxtNull;
        data->editor_data.TextString             = NULL; /* no label */
        data->editor_data.min_enter              = 0;
        if( (data->sat_command->qual & SAT_M_TEXT_WAIT) NEQ 0 )
        {
            data->editor_data.timeout         = TWO_MIN;
            data->editor_data.Identifier      = SAT_DISPLAY_TEXT_WAIT;
        }
        else
        {
            data->editor_data.timeout         = TEN_SECS;
            data->editor_data.Identifier      = event;
        }

        /* provide a buffer, containing the string to be displayed */
        memset(data->info_buffer, '\0', sizeof(data->info_buffer));   
        data->info_buffer   = sat_create_TEXT_ASCIIZ (&sat_command->c.text);//zhaowm

        /*
         * Start the Editor
         */

        if( editor_start_common (win, data->info_buffer, sat_command->c.text.len+1, &data->editor_data, (T_EDIT_CB)sat_editor_cb) == NULL )
        //      data->display_editor=editor_start_common (win, data->info_buffer, sat_command->c.text.len+1, &data->editor_data, (T_EDIT_CB)sat_editor_cb);//zhaowm2002/12/05
        //      if (data->display_editor== NULL)
        //if (editor_start_common (win, data->info_buffer, sat_command->c.text.len+1, &data->editor_data, (T_EDIT_CB)sat_editor_cb)== NULL )//zhaowm
        {
            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_display_text_destroy (data->win);
        }
        break;

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

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


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

 $Function:    	sat_ASCII_to_TEXT

 $Description:	This routine converts an ASCIIZ string into an MFW SAT text 
                descriptor the coding scheme is taken accordign to the code in <txt>

 $Returns:		none

 $Arguments:	txt  - text info
                destination - text destination 
                source - text source

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

static void sat_ASCII_to_TEXT (T_SAT_TXT * txt, UBYTE * destination, UBYTE * source)
{
    UBYTE * temp_buffer;

    switch( txt->code )
    {
    case MFW_DCS_7bits:
        temp_buffer = (UBYTE *)ALLOC_MEMORY(txt->len+1); 
        sat_ascii_to_gsm ((char *)temp_buffer, (char *)source, (U16)(txt->len));
        utl_cvt8To7 (temp_buffer, txt->len, destination, 0);
        FREE_MEMORY ((U8 *)temp_buffer, txt->len+1);
        break;
    case MFW_DCS_8bits:
        sat_ascii_to_gsm ((char *)destination, (char *)source, (U16)(txt->len));
        break;
    case MFW_DCS_UCS2:
        sat_ascii_to_ucode ((wchar_t *)destination, (char *)source, (U16)(txt->len));
        break;
    default:
        sat_ascii_to_gsm ((char *)destination, (char *)source, (U16)(txt->len));
        TRACE_EVENT("sat_ASCII_to_TEXT() unexp. DCS");
        break;
    }
}

#ifdef INTEGRATION_SEPT00

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

 $Function:    	sat_UCODE_to_TEXT

 $Description:	This routine converts an UCODE string into an MFW SAT text descriptor
            the coding scheme is taken accordign to the code in <txt>

⌨️ 快捷键说明

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