📄 mmismssend.c
字号:
/*******************************************************************************
$Function: SmsSend_SAVE_start
$Description: Create the Save SMS text window.
$Returns: mfw window handle
$Arguments: parent_window - parent window
UserData - SMS info
*******************************************************************************/
T_MFW_HND SmsSend_SAVE_start(T_MFW_HND parent_window, T_SmsUserData *UserData)
{
T_MFW_HND win;
TRACE_FUNCTION ("SmsSend_SAVE_start()");
win = SmsSend_SAVE_create (parent_window);
if (win NEQ NULL)
{
SEND_EVENT (win, E_INIT, 0, (void *)UserData);
}
return win;
}
/*******************************************************************************
$Function: SmsSend_SAVE_create
$Description: Create a window for info dialog
$Returns: mfw window handle
$Arguments: parent_window - parent window
*******************************************************************************/
static T_MFW_HND SmsSend_SAVE_create(MfwHnd parent_window)
{
T_SAVE * data = (T_SAVE *)ALLOC_MEMORY (sizeof (T_SAVE));
T_MFW_WIN * win;
TRACE_FUNCTION ("SmsSend_SAVE_create()");
/*
* Create window handler
*/
data->win = win_create (parent_window, 0, E_WIN_VISIBLE, NULL);
if (data->win EQ NULL)
{
return NULL;
}
/*
* connect the dialog data to the MFW-window
*/
data->mmi_control.dialog = (T_DIALOG_FUNC)SmsSend_SAVE_exec_cb;
data->mmi_control.data = data;
win = ((T_MFW_HDR *)data->win)->data;
win->user = (MfwUserDataPtr)data;
data->parent = parent_window;
data->id = SAVE_ID;
winShow(data->win);
return data->win;
}
/*******************************************************************************
$Function: SmsSend_SAVE_destroy
$Description: Destroy the windows for info dialog
$Returns: none
$Arguments: own_window - current window
*******************************************************************************/
static void SmsSend_SAVE_destroy(MfwHnd own_window)
{
T_MFW_WIN * win_data;
T_SAVE * data = NULL;
TRACE_FUNCTION ("SmsSend_SAVE_destroy()");
if (own_window)
{
win_data = ((T_MFW_HDR *)own_window)->data;
if (win_data)
data = (T_SAVE *)win_data->user;
if (data)
{
// Delete sms handle
if (data->sms_handler != NULL)
sms_delete(data->sms_handler);
if (data->child_dialog != NULL)
{
TRACE_EVENT("child_dialog not deleted?");
}
// Delete WIN handler
win_delete (data->win);
// Free Memory
FREE_MEMORY ((void *)data, sizeof (T_SAVE));
}
else
{
TRACE_EVENT ("SmsSend_SAVE_destroy() called twice");
}
}
}
/*******************************************************************************
$Function: SmsSend_SAVE_exec_cb
$Description: Callback handler for events sent to to trigger execution
$Returns: none
$Arguments: own_window - current window
*******************************************************************************/
void SmsSend_SAVE_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
{
T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
T_SAVE * data = (T_SAVE *)win_data->user;
T_MFW_SMS_INFO sms_parameter;
USHORT outLen;
T_MFW store_status;
/*JVJ SPR1298 made dynamic to avoid stack overload in the function convertToUnicodeForOutput*/
UBYTE* msgBuffer = (UBYTE*)ALLOC_MEMORY(MAX_MSG_LEN_ARRAY);
TRACE_FUNCTION ("SmsSend_SAVE_exec_cb()");
switch (event)
{
case E_INIT:
data->child_dialog = NULL;
/* Create a sms handler to receive events */
data->sms_handler = sms_create(data->win,
E_SMS_SAVE_AVAIL | E_SMS_ERR | E_SMS_MEM_FULL
,(MfwCb)SmsSend_SAVE_mfw_cb);
// Copy the input data in the private structure of the window
memcpy(&data->edt_data, (T_SmsUserData *)parameter, sizeof(T_SmsUserData));
if (data->edt_data.TextBuffer[0] == 0x80)
{ //String is unicode -
sms_parameter.dcs = MFW_DCS_UCS2;
}
else
{
sms_parameter.dcs = MFW_DCS_7bits;
}
SmsSend_set_dcs_number (&sms_parameter);
#ifdef NO_ASCIIZ
{
// have to add this , later
convertToUnicodeForOutput(data->edt_data.TextBuffer,msgBuffer, &outLen);
TRACE_EVENT_P1("Save SMS, length: %d", outLen);
store_status = sms_store(MFW_SMS_SUBMIT, (char*)data->edt_data.NumberBuffer, msgBuffer, outLen, NULL);
}
#else
{
convertToUnicodeForOutput(data->edt_data.TextBuffer,msgBuffer, &outLen);
store_status = sms_store(MFW_SMS_SUBMIT, (char*)data->edt_data.NumberBuffer, msgBuffer, outLen, NULL);
// sbh - added length to the above function call, since '@' characters stored as NULL & will stop
// strlen from working properly.
}
#endif
/* display "Please wait" for save sms */
if (store_status EQ MFW_SMS_OK)
{
TRACE_EVENT ("Save operation -> ok");
/* show now to user "Please wait" for save*/
// Do not start please wait if ever the MFW result event as already been received
if (data->child_dialog == NULL)
data->child_dialog = mmi_dialog_information_screen(win,TxtPleaseWait, "SAVING", (T_VOID_FUNC)SmsSend_standard_dialog_cb, SMSSEND_ID_WAIT_SAVE);
}
else
{
TRACE_EVENT ("Save operation -> failed");
// If the memory full event has already been received do not display this message
if (data->child_dialog == NULL)
mmi_dialog_information_screen(win, TxtFailed,"NOT SAVED", (T_VOID_FUNC)SmsSend_standard_dialog_cb, SMSSEND_ID_NOT_SAVED);
}
break;
default:
TRACE_EVENT("Err: default");
break;
}
FREE_MEMORY((void*)msgBuffer,MAX_MSG_LEN_ARRAY);
return;
}
/*******************************************************************************
$Function: SmsSend_SAVE_mfw_cb
$Description: Handles SMS events from the MFW.
$Returns: none
$Arguments: event - event id
info - optional info
*******************************************************************************/
static int SmsSend_SAVE_mfw_cb (MfwEvt event, void *info)
{
/* get the top window*/
T_MFW_HND win = mfw_parent(mfw_header());
T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
T_SAVE * data = (T_SAVE *)win_data->user;
// T_DISPLAY_DATA display_info;
TRACE_FUNCTION ("SmsSend_SAVE_mfw_cb");
switch (event)
{
/* Save is successful */
case E_SMS_SAVE_AVAIL:
// Waiting dialog is destroyed
if (data->child_dialog != NULL)
{
SEND_EVENT (data->child_dialog, DIALOG_DESTROY, 0, NULL);
data->child_dialog = NULL;
}
mmi_dialog_information_screen(win, TxtSaved,"SAVED", (T_VOID_FUNC)SmsSend_standard_dialog_cb, SMSSEND_ID_SAVED);
break;
case E_SMS_MEM_FULL:
TRACE_EVENT ("Memory for sms save is full");
if (data->child_dialog != NULL)
{
// Waiting dialog is destroyed
SEND_EVENT (data->child_dialog, DIALOG_DESTROY, 0, NULL);
data->child_dialog = NULL;
}
// and the status dialog is displayed during 3 secs.
// set data->child_dialog as message received before sms_store is ended
mmi_dialog_information_screen(win,TxtFull, "LIST FULL", (T_VOID_FUNC)SmsSend_standard_dialog_cb, SMSSEND_ID_LIST_FULL);
break;
case E_SMS_ERR:
TRACE_EVENT ("Save sms failed -> nok");
if (data->child_dialog != NULL)
{
// Waiting dialog is destroyed
SEND_EVENT (data->child_dialog, DIALOG_DESTROY, 0, NULL);
data->child_dialog = NULL;
}
// and the status dialog is displayed during 3 secs.
// set data->child_dialog if message received before sms_store is ended
mmi_dialog_information_screen(win,TxtFailed, "NOT SAVED", (T_VOID_FUNC)SmsSend_standard_dialog_cb, SMSSEND_ID_NOT_SAVED);
break;
default:
TRACE_EVENT("Err: default");
return 0;
}
return 1;
}
/*******************************************************************************
$Function: SmsSend_send_to_mfw
$Description: This function sends a SMS message.
$Returns: execution status
$Arguments: event - current window
$History
GW 09/10/01 - Added code to convert unicode strings from 8 bits to 7 bits.
*******************************************************************************/
static int SmsSend_send_to_mfw (T_MFW_HND win)
{
T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
T_SEND * data = (T_SEND *)win_data->user;
T_MFW submit_status; /* Result of SMS send operation. */
T_MFW_SMS_INFO sms_parameter;
/*JVJ SPR1298 made dynamic to avoid stack overload in the function convertToUnicodeForOutput*/
UBYTE* msgBuffer = (UBYTE*)ALLOC_MEMORY(MAX_MSG_LEN_ARRAY);
USHORT outLen;
TRACE_FUNCTION ("SmsSend_send_to_mfw()");
if (data->edt_data.TextBuffer[0] == 0x80)
{ //String is unicode -
sms_parameter.dcs = MFW_DCS_UCS2;
}
else
{
sms_parameter.dcs = MFW_DCS_7bits;
}
SmsSend_set_dcs_number (&sms_parameter);
/* Send the SMS */
#ifdef NO_ASCIIZ
{
convertToUnicodeForOutput(data->edt_data.TextBuffer,msgBuffer, &outLen);
TRACE_EVENT_P1("Send SMS, length: %d", outLen);
submit_status = sms_submit( MFW_SMS_SUBMIT, /* type of the message*/
(char *)data->edt_data.NumberBuffer, /* dest. address */
msgBuffer, /* sms message */
outLen, /* lenght of message */
(char *)data->edt_data.CentreBuffer);/* sevice center num. */
}
#else
{
convertToUnicodeForOutput(data->edt_data.TextBuffer,msgBuffer,&outLen);
submit_status = sms_submit( MFW_SMS_SUBMIT, /* type of the message*/
(char *)data->edt_data.NumberBuffer, /* dest. address */
msgBuffer, /* sms message */
outLen, // sbh - added this, see function definition
(char *)data->edt_data.CentreBuffer);/* sevice center num. */
}
#endif
/* display "Please wait" for sent sms */
if (submit_status EQ MFW_SMS_OK)
{
T_DISPLAY_DATA display_info;
TRACE_EVENT ("to give SMS to MFW -> ok");
/* show the use "Please wait" for send sms */
dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtSending, TxtMessage , COLOUR_STATUS);
dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)SmsSend_standard_dialog_cb, FOREVER, KEY_LEFT );
display_info.Identifier = SMSSEND_ID_WAIT_SEND;
data->child_dialog = info_dialog(win, &display_info);
data->id = SMSSEND_ID_SENT;
}
else
{
TRACE_EVENT ("to give SMS to MFW -> failed");
/* the result operation of sent was NOT OK*/
mmi_dialog_information_screen(win,TxtNotSent, "NOT SENT", (T_VOID_FUNC)SmsSend_standard_dialog_cb, SMSSEND_ID_NOT_SENT);
// No forever dialog to be destroyed
data->child_dialog = NULL;
data->id = SMSSEND_ID_NOT_SENT;
}
FREE_MEMORY((void*)msgBuffer,MAX_MSG_LEN_ARRAY);
return 1;
}
/*******************************************************************************
$Function: SmsSend_get_config_data
$Description: Called by external processes to read SMS PP config data.
$Returns: execution status
$Arguments: config_data - SMS info
*******************************************************************************/
UBYTE SmsSend_get_config_data (T_MFW_SMS_INFO *config_data)
{
T_MFW Submit_Status; /* store theh result of SMS send operation. */
TRACE_FUNCTION ("SmsSend_get_config_data()");
// get the current config data from SIM
Submit_Status = sms_parameter(config_data, TRUE);
if (Submit_Status == MFW_SMS_FAIL)
{
TRACE_EVENT ("ret MFW_SMS_FAIL");
return FALSE;
}
else
{
TRACE_EVENT ("ret OK");
return TRUE;
}
}
/*******************************************************************************
$Function: Sm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -