📄 mmismsread.c
字号:
len = opLength/2;
opString[len*2] = 0x00;
opString[len*2+1] = 0x00;
}
else
{
if (len>opLength)
len = opLength;
opString[len] = 0x00;
}
/* end SPR925 */
}
FREE_MEMORY(text_8bit,MAX_EDITOR_LEN+1);
return TRUE;
}
/**/
/*******************************************************************************
$Function: SmsRead_R_start
$Description: Start the creation of the main window for SMS reading
$Returns: mfw window handler
$Arguments: parent_window - Parent window handler
menuAttr - Menu attributes.
*******************************************************************************/
T_MFW_HND SmsRead_R_start(T_MFW_HND parent_window, MfwMnuAttr *menuAttr)
{
T_MFW_HND win;
TRACE_FUNCTION ("SmsRead_R_start()");
win = SmsRead_R_create (parent_window);
if (win NEQ NULL)
{
/* We transmit to the SMS editor the address of the data buffer */
SEND_EVENT (win, E_INIT, SmsRead_R_ID, (void *)menuAttr);
}
return win;
}
/*******************************************************************************
$Function: SmsRead_R_create
$Description: create the SMS read window (dynamic list of all the SMS)
$Returns: mfw window handler
$Arguments: parent_window - Parent window handler
*******************************************************************************/
static T_MFW_HND SmsRead_R_create(MfwHnd parent_window)
{
T_SMSREAD_R * data = (T_SMSREAD_R *)ALLOC_MEMORY (sizeof (T_SMSREAD_R));
T_MFW_WIN * win;
TRACE_FUNCTION ("SmsRead_R_create()");
/*
* Create window handler
*/
data->win =
win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)SmsRead_R_win_cb);
if (data->win EQ NULL)
{
return NULL;
}
/*
* connect the dialog data to the MFW-window
*/
data->mmi_control.dialog = (T_DIALOG_FUNC)SmsRead_R_exec_cb;
data->mmi_control.data = data;
win = getWinData(data->win);
win->user = (void *)data;
data->parent = parent_window;
winShow(data->win);
/*
* return window handle
*/
return data->win;
}
/*******************************************************************************
$Function: SmsRead_R_destroy
$Description: Destroy the SMS read window (dynamic list of all the SMS)
$Returns: none
$Arguments: own_window - window handler
*******************************************************************************/
static void SmsRead_R_destroy(MfwHnd own_window)
{
T_MFW_WIN * win_data;
T_SMSREAD_R * data;
USHORT i;
TRACE_FUNCTION ("SmsRead_R_destroy()");
if (own_window)
{
win_data = getWinData(own_window); //((T_MFW_HDR *))->data;
data = getUserData_T_SMSREAD_R(win_data);
if (data)
{
/*
* Delete WIN handler
*/
sms_delete(data->sms_handle);
if (info_win)
{
SEND_EVENT(info_win,DIALOG_DESTROY,0,0 );
info_win = 0;
}
if (list_win){
SEND_EVENT(info_win,DIALOG_DESTROY,0,0 );
list_win = 0;
}
win_delete (data->win);
/*
* Free Memory
*/
/* Free the data allocated for the name associated to the phone number */
if (data->sms_editor_data.assoc_name != NULL)
FREE_MEMORY( (void *)data->sms_editor_data.assoc_name, strlen(data->sms_editor_data.assoc_name) + 1);
/* Free the data allocated for the dynamic list */
if (data->menu_list_data != NULL)
{
for (i = 0; i < ((data->sms_list_data).nb_sms_stored); i++)
{
FREE_MEMORY( (void *)data->sms_list_data.sms_header[i], UCS2_MENU_TEXT_LEN+ 1/*SPR1242*/);
}
FREE_MEMORY ((void *)data->menu_list_data->List,MAX_MESSAGES * sizeof(T_MFW_MNU_ITEM));
FREE_MEMORY ((UBYTE *)data->menu_list_data, sizeof(ListMenuData));
}
FREE_MEMORY ((void *)data, sizeof (T_SMSREAD_R));
}
else
{
TRACE_EVENT ("SmsRead_R_destroy() called twice");
}
}
}
/*******************************************************************************
$Function: SmsRead_R_exec_cb
$Description: Exec callback function of the SMS read window (dynamic list of
all the SMS)
$Returns: none
$Arguments: win - window handler
event - mfw event
parameter - optional data.
*******************************************************************************/
void SmsRead_R_exec_cb (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
/* callback handler for events sent to to trigger execution */
{
T_MFW_WIN * win_data;
T_SMSREAD_R * data;
T_SMS_LIST_DATA * list_data;
T_MFW_EVENT MfwEvents;
T_MFW_SMS_STAT sms_list_type = *(T_MFW_SMS_STAT *)parameter;
T_MFW_HND l_parent;
T_DISPLAY_DATA DisplayInfo;
// Status of SMS reading
T_MFW status;
win_data = getWinData(win); //((T_MFW_HDR *))->data;
data = getUserData_T_SMSREAD_R(win_data);
list_data = &data->sms_list_data;
TRACE_FUNCTION ("SmsRead_R_exec_cb()");
switch (event)
{
case E_INIT:
/* initialization of administrative data */
info_win=0;
data->id = value;
data->menu_list_data = NULL;
//NM 24.8
/* Verify that SMS handling has been correctly initialised */
if (!smsidle_get_ready_state())
{
SmsMenu_loadDialogDefault(&DisplayInfo);
DisplayInfo.TextId = TxtPleaseWait;
//DisplayInfo.TextId2 = TxtReady;
// Generic function for info messages
DisplayInfo.Callback = (T_VOID_FUNC)SmsRead_R_dialog_cb;
info_dialog(win, &DisplayInfo);
break;
}
/* We have to handle E_SMS_MO and E_SMS_MT MFW events, in order to retrieve the SMS */
MfwEvents = E_SMS_MT | E_SMS_MO | E_SMS_MT_RECEIVED | E_SMS_MO_AVAIL|
E_SMS_ERR | E_SMS_OK | E_SMS_MEM_FREE | E_SMS_MEM_FULL;
data->sms_handle = sms_create(win,MfwEvents,(MfwCb)SmsRead_R_mfw_cb);
/* Get info on the stored messages
According to sms_list_type filter some specific type (new, read...) */
/* JVJ SPR-1298 Memory optimization : Replace sms_message_list with sms_index_list, which requires less RAM*/
list_data->nb_sms_stored = sms_index_list(sms_list_type, list_data->sms_messages, MAX_MESSAGES);
/* we want to get the whole SMS list */
if (list_data->nb_sms_stored > 0)
{
if (!info_win)
info_win = mmi_dialog_information_screen_forever(win,TxtPleaseWait, NULL, COLOUR_STATUS_WAIT);
// We want to read all the SMS
g_sms_state = READ_SMS_LIST;
/* global counter to decrement each time a message is read */
g_sms_list_counter = list_data->nb_sms_stored - 1;
/* Initialise counter for number of entries in sms list. used to call the correct
no of FreeAllocs MZ 8/03/01 */
g_nb_line_sms =0;
status = sms_read(MFW_SMS_MESSAGE, (unsigned char)(list_data->sms_messages[g_sms_list_counter]).index);
}
else
SmsRead_DisplayStandardDialog(win, TxtNoMessages, THREE_SECS);
break;
case E_RETURN:
/* Call the recreate function that will create and display a dynamic list from the list of SMS */
listDisplayListMenu(win, data->menu_list_data, (ListCbFunc_t)SmsRead_R_smslist_cb,0);
break;
case E_BACK:
/* Received an E_BACK event from the dynamic list --> suicide and E_RETURN to parent */
l_parent = data->parent;
SmsRead_R_destroy(win);
SEND_EVENT(l_parent, E_RETURN, data->id, NULL);
case E_EXIT: // Terminate exit from sms send...
listDisplayListMenu(win, data->menu_list_data, (ListCbFunc_t)SmsRead_R_smslist_cb,0);
break;
default:
break;
}
}
/*******************************************************************************
$Function: SmsRead_R_win_cb
$Description: Window callback function of the SMS read window (dynamic list of
all the SMS)
$Returns: none
$Arguments: w - mfw window handler
e - mfw event
*******************************************************************************/
static int SmsRead_R_win_cb (MfwEvt e, MfwWin *w) /* yyy window event handler */
{
TRACE_FUNCTION ("SmsRead_R_win_cb()");
switch (e)
{
case MfwWinVisible: /* window is visible */
break;
case MfwWinFocussed: /* input focus / selected */
case MfwWinDelete: /* window will be deleted */
default:
return MFW_EVENT_REJECTED;
}
return MFW_EVENT_CONSUMED;
}
/*******************************************************************************
$Function: SmsRead_GetStatusText
$Description: Function to copy status string into array provided.
$Returns: number of characters used in the output array.
$Arguments: op_text_str - pointer to array to store the string
status - read status of text message.
$History
SPR#780-GW-Created to allow consistent display of status in text message list
*******************************************************************************/
int SmsRead_GetStatusText( char* op_text_str, int status)
{
int txt_len, txtId;
TRACE_FUNCTION("SmsRead_GetStatusText()");
if (status == MFW_SMS_READ)
txtId = TxtOld;
else if(status == MFW_SMS_UNREAD)
txtId = TxtNew;
else if(status == MFW_SMS_STOR_UNSENT)
txtId = TxtSaved;
else if(status == MFW_SMS_STOR_SENT)
txtId = TxtSend;
else //assume if it is not marked as new/old/sent/unsent
txtId = TxtNull;
// Check for the READ/UNREAD status of the MT message.
if (Mmi_getCurrentLanguage() != CHINESE_LANGUAGE)
{
strcpy(op_text_str,MmiRsrcGetText(txtId));
/* Only add colon if a non-empty string */
if (txtId != TxtNull)
strcat(op_text_str,":");
txt_len = strlen(op_text_str);
}
else //language = Chinese, copy unicode string
{
USHORT* unicodeStr;
USHORT* txtStr;
int uIndex;
unicodeStr = charPtrToUSHORTPtr(op_text_str);
txtStr = charPtrToUSHORTPtr(MmiRsrcGetText(txtId));
uIndex = 0;
txt_len = 0;
while ((*txtStr!= 0) && (uIndex*2 <MENU_TEXT_LENGTH))
{
unicodeStr[uIndex] = *txtStr;
txtStr++;
uIndex++;
txt_len = txt_len+2; // 2bytes per chinese char
}
if ((uIndex*2 <MENU_TEXT_LENGTH) && (txtId != TxtNull))
{
unicodeStr[uIndex] = ((charToUSHORT)(':'))<<8;
uIndex++;
txt_len = txt_len+2; // 2bytes per chinese char
}
}
/* Return number of characters copied into the array */
return (txt_len);
}
/*******************************************************************************
$Function: SmsRead_R_mfw_cb
$Description: MFW callback function of the SMS read window (dynamic list of all the SMS).
Only interesting events for reading are handled here
$Returns: event status
$Arguments: parameter - optional data
event - mfw event
*******************************************************************************/
int SmsRead_R_mfw_cb(MfwEvt event, void *parameter)
{
T_MFW_HND win = mfwParent((MfwHdr *)mfw_header());
T_MFW_WIN * win_data;
T_SMSREAD_R * data;
T_SMS_LIST_DATA * list_data;
T_MFW_SMS_MO * MoMessage;
T_MFW_SMS_MT * MtMessage;
T_MFW_SMS_IDX msg_info;
UBYTE input_type;/*SPR1242, UCS2 or GSM string*/
T_DISPLAY_DATA DisplayInfo;
int input_length = 0; /*MC, SPR 1453*/
BOOL unicode = FALSE;/*MC, SPR 1442*/
USHORT sms_len;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -