短信编辑完成后会进入函数mmi_msg_entry_send_option()中,其函数实现如下:
[SmsMoMtGuiInterface.c]
void mmi_msg_entry_send_option(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 *guiBuffer = NULL;
U16 numItems = 0;
U16 nStrItemList[MAX_SUB_MENUS];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_COMMON_TRC_G6_MSG, TRC_MMI_SMS_ENTRY_SEND_OPTION, g_msg_cntx.sendMessageCase);
if (g_msg_cntx.sendMessageCase == SEND_CASE_REPLY)
{
mmi_msg_reply_msg();// 答复信息
return;
}
else if (g_msg_cntx.sendMessageCase == SEND_CASE_SEND_FROM_PHB)
{
mmi_msg_send_msg_to_only_entry(); // 从电话本中发送短信
return;
}
else if (g_msg_cntx.sendMessageCase == SEND_CASE_SEND_FROM_USE_NUMBER)
{
g_msg_cntx.msg_send_info.CurrSendSmsNumbers = 0;
g_msg_cntx.msg_send_info.TotalSendSmsNumbers = 1;
mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, MMI_FRM_SMS_INVALID_INDEX, 1);
return;
}
else if (g_msg_cntx.sendMessageCase == SEND_CASE_REPLY_FROM_OTHER_APP)
{
g_msg_cntx.msg_send_info.CurrSendSmsNumbers = 0;
g_msg_cntx.msg_send_info.TotalSendSmsNumbers = 1;
mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, MMI_FRM_SMS_INVALID_INDEX, 0);
return;
}
EntryNewScreen(SCR_ID_MSG_SEND_OPTION, mmi_msg_exit_generic, mmi_msg_entry_send_option, NULL);
if (g_msg_cntx.sendMessageCase != SEND_CASE_SEND_FROM_OTHER_APP)
{
g_msg_cntx.sendMessageCase = SEND_CASE_SEND_ONLY; /* reset,仅发送,不保存*/
}
guiBuffer = GetCurrGuiBuffer(SCR_ID_MSG_SEND_OPTION);// 获取当前窗口的gui buffer
#ifndef __MMI_DUAL_SIM_MASTER__ // 单卡情况
{
numItems = GetNumOfChild(EMS_ED_OPT_DONE); // 获取列表窗口的子菜单数目
GetSequenceStringIds(EMS_ED_OPT_DONE, nStrItemList); // 获取要显示的字符串序列
SetParentHandler(EMS_ED_OPT_DONE); // 设置当前窗口的父窗口的ID
}
#else /* else not define __MMI_DUAL_SIM_MASTER__ */ // 双卡情况
switch (MTPNP_AD_Get_Channel(MTPNP_AD_SMS_CHANNEL)) // 函数MTPNP_AD_Get_Channel用来获取通信信道的
{
case MTPNP_AD_CHANNEL_MASTER: // sim卡1
{
numItems = GetNumOfChild_Ext(EMS_ED_OPT_DONE);
GetSequenceStringIds_Ext(EMS_ED_OPT_DONE, nStrItemList);
SetParentHandler(EMS_ED_OPT_DONE);
break;
}
case MTPNP_AD_CHANNEL_SLAVE: // sim卡2
{
numItems = GetNumOfChild_Ext(MENU_MTPNP_EMS_ED_OPT_DONE);
GetSequenceStringIds_Ext(MENU_MTPNP_EMS_ED_OPT_DONE, nStrItemList);
SetParentHandler(MENU_MTPNP_EMS_ED_OPT_DONE);
break;
}
case MTPNP_AD_CHANNEL_DEFAULT_MASTER:
case MTPNP_AD_CHANNEL_DEFAULT_SLAVE:
default:
{
numItems = GetNumOfChild_Ext(EMS_ED_OPT_DONE);
GetSequenceStringIds_Ext(EMS_ED_OPT_DONE, nStrItemList);
SetParentHandler(EMS_ED_OPT_DONE);
break;
}
}
#endif /* end define __MMI_DUAL_SIM_MASTER__ */
RegisterHighlightHandler(ExecuteCurrHiliteHandler); // 注册highlight 函数
SetMessagesCurrScrnID(SCR_ID_MSG_SEND_OPTION); // 设置当前屏幕ID
#ifdef __MMI_UNIFIED_MESSAGE__ // 只有一个卡存在时
if ((IsScreenPresent(SCR_ID_MSG_WRITE))||
(IsScreenPresent(SCR_ID_UM_INBOX)) ||
(IsScreenPresent(SCR_ID_UM_UNSENT))||
(IsScreenPresent(SCR_ID_UM_SENT))
#ifdef __UNIFIED_MESSAGE_ARCHIVE_SUPPORT__
||(IsScreenPresent(SCR_ID_UM_ARCHIVE))
#endif
)
{
int i = 0;
for (i = 0; i < MAX_SUB_MENUS; i++)
{
if (nStrItemList[i] == STR_GLOBAL_SAVE)
{
nStrItemList[i] = STR_SMS_SAVE_TO_DRAFTS_MENU_ITEM; //保存到草稿箱
break;
}
}
}
#endif /* __MMI_UNIFIED_MESSAGE__ */
#ifndef __MMI_DUAL_SIM_MASTER__ // 单卡情况
ShowCategory52Screen(STR_SEND_OPTIONS_CAPTION,
IMG_SMS_ENTRY_SCRN_CAPTION,
STR_GLOBAL_OK,
IMG_GLOBAL_OK,
STR_GLOBAL_BACK,
IMG_GLOBAL_BACK,
numItems,
nStrItemList,
(U16*) gIndexIconsImageList,
NULL,
0,
0,
guiBuffer);
#else /* else not define __MMI_DUAL_SIM_MASTER__ */ // 双卡情况
{
switch (MTPNP_AD_Get_Channel(MTPNP_AD_SMS_CHANNEL))
{
case MTPNP_AD_CHANNEL_MASTER:
ShowCategory52Screen(STRING_MTPNP_MASTER_SEND_OPTIONS_CAPTION,
IMG_SMS_ENTRY_SCRN_CAPTION,
STR_GLOBAL_OK,
IMG_GLOBAL_OK,
STR_GLOBAL_BACK,
IMG_GLOBAL_BACK,
numItems,
nStrItemList,
(U16*) gIndexIconsImageList,
NULL,
0,
0,
guiBuffer);
break;
case MTPNP_AD_CHANNEL_SLAVE:
ShowCategory52Screen(STRING_MTPNP_SLAVE_SEND_OPTIONS_CAPTION,
IMG_SMS_ENTRY_SCRN_CAPTION,
STR_GLOBAL_OK,
IMG_GLOBAL_OK,
STR_GLOBAL_BACK,
IMG_GLOBAL_BACK,
numItems,
nStrItemList,
(U16*) gIndexIconsImageList,
NULL,
0,
0,
guiBuffer);
break;
case MTPNP_AD_CHANNEL_DEFAULT_MASTER:
case MTPNP_AD_CHANNEL_DEFAULT_SLAVE:
default:
ShowCategory52Screen(STR_SEND_OPTIONS_CAPTION,
IMG_SMS_ENTRY_SCRN_CAPTION,
STR_GLOBAL_OK,
IMG_GLOBAL_OK,
STR_GLOBAL_BACK,
IMG_GLOBAL_BACK,
numItems,
nStrItemList,
(U16*) gIndexIconsImageList,
NULL,
0,
0,
guiBuffer);
break;
}
}
#endif /* end define __MMI_DUAL_SIM_MASTER__ */
}
此函数执行完后便进入了短信发送选项屏幕,我们按“发送”菜单,之后便会进入函数mmi_msg_send_msg_to_only_entry(),下面让我们来看看这个函数的实现:
[SmsPsHandler.c]
void mmi_msg_send_msg_to_only_entry(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
#ifdef __MMI_MESSAGES_SMS_EMAIL__
U8 PhbNum[MAX_SMS_EMAIL_NUMBER + 1] = {0};
#endif
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_msg_cntx.msg_send_info.CurrSendSmsNumbers = 0;
g_msg_cntx.msg_send_info.TotalSendSmsNumbers = 1;
// 因为在mmi_msg_entry_send_option()函数中我们已经将g_msg_cntx.sendMessageCase赋值为
// SEND_CASE_SEND_ONLY,所以程序不会进入if分支,而会进入else if分支
/* pressing SEND key from send to many phone number editor or send message from phonebook */
if (g_msg_cntx.sendMessageCase == SEND_CASE_SEND_TO_MANY || g_msg_cntx.sendMessageCase == SEND_CASE_SEND_FROM_PHB)
{
S8 phonenumber[(MAX_DIGITS + 1) * ENCODING_LENGTH];
U8 length = mmi_ucs2strlen(g_msg_cntx.smsPhoneNumber);
/* The length should be extracted by 1 for the sake of handling odd number of ascii phone number characters. */
kal_bool isAsciiNumber = mmi_msg_check_ascii_number((U8*) g_msg_cntx.smsPhoneNumber, (U16) (length * ENCODING_LENGTH - 1));
if (length == 0)
{
DisplayPopup((PU8) GetString(STR_SMS_NUM_CANNOT_BE_EMPTY),
IMG_GLOBAL_UNFINISHED,
1,
MESSAGES_POPUP_TIME_OUT,
(U8) ERROR_TONE);
return;
}
/* convert g_msg_cntx.smsPhoneNumber from unicode to ascii */
if (!isAsciiNumber)
{
memset(phonenumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
mmi_ucs2ncpy(phonenumber, g_msg_cntx.smsPhoneNumber, length * ENCODING_LENGTH);
memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
mmi_ucs2_n_to_asc((S8*) g_msg_cntx.smsPhoneNumber, (S8*) phonenumber, length * ENCODING_LENGTH);
}
}
else if (g_msg_cntx.sendMessageCase != SEND_CASE_SEND_FROM_PHB &&
g_msg_cntx.sendMessageCase != SEND_CASE_SEND_FROM_USE_NUMBER &&
g_msg_cntx.sendMessageCase != SEND_CASE_REPLY_FROM_OTHER_APP &&
g_msg_cntx.sendMessageCase != SEND_CASE_SEND_FROM_OTHER_APP)
{
memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
#ifdef __MMI_UNIFIED_MESSAGE__ // 只有一个卡存在时
if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT)
{
memcpy(g_msg_cntx.smsPhoneNumber,
(S8*) mmi_frm_sms_get_address(MMI_FRM_SMS_UNSENT, (U16) g_msg_cntx.currBoxIndex),
MAX_DIGITS_SMS);
#ifdef __MMI_MESSAGES_SMS_EMAIL__
if (g_msg_cntx.send_type == SEND_CASE_SEND_EMAIL)
{
mmi_ucs2_n_to_asc((S8*) PhbNum, (S8*) g_msg_cntx.smsEmailAddress, mmi_ucs2strlen(g_msg_cntx.smsEmailAddress) * ENCODING_LENGTH);
}
#endif /* __MMI_MESSAGES_SMS_EMAIL__ */
}
else if (mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_DRAFT)
{
memcpy(g_msg_cntx.smsPhoneNumber,
(S8*) mmi_frm_sms_get_address(MMI_FRM_SMS_DRAFTS, (U16) g_msg_cntx.currBoxIndex),
MAX_DIGITS_SMS);
#ifdef __MMI_MESSAGES_SMS_EMAIL__
if (g_msg_cntx.send_type == SEND_CASE_SEND_EMAIL)
{
mmi_ucs2_n_to_asc((S8*) PhbNum, (S8*) g_msg_cntx.smsEmailAddress, mmi_ucs2strlen(g_msg_cntx.smsEmailAddress) * ENCODING_LENGTH);
}
#endif /* __MMI_MESSAGES_SMS_EMAIL__ */
}
#else /* __MMI_UNIFIED_MESSAGE__ */
#ifndef __MMI_DUAL_SIM_MASTER__
// 这里GetMessagesCurrScrnID()的值为SCR_ID_MSG_SEND_OPTION
if (GetMessagesCurrScrnID() == SCR_ID_MSG_OUTBOX_SEND_OPTION)
#else /* __MMI_DUAL_SIM_MASTER__ */
if (GetMessagesCurrScrnID() == SCR_ID_MSG_OUTBOX_SEND_OPTION ||
GetMessagesCurrScrnID() == SCR_MTPNP_MSG_OUTBOX_SEND_OPTION)
#endif /* __MMI_DUAL_SIM_MASTER__ */
{
#ifdef __MMI_MESSAGES_DRAFT_BOX__
// 函数IsScreenPresent()的功能是查询历史记录的屏幕ID是否存在
if (IsScreenPresent(SCR_ID_MSG_DRAFTBOX_LIST))
{
memcpy(
g_msg_cntx.smsPhoneNumber,
(S8*) mmi_frm_sms_get_address(MMI_FRM_SMS_APP_DRAFTS, (U16) g_msg_cntx.currBoxIndex),
MAX_DIGITS_SMS);
}
else
#endif /* __MMI_MESSAGES_DRAFT_BOX__ */
memcpy(
g_msg_cntx.smsPhoneNumber,
(S8*) mmi_frm_sms_get_address(MMI_FRM_SMS_APP_OUTBOX, (U16) g_msg_cntx.currBoxIndex),
MAX_DIGITS_SMS);
#ifdef __MMI_MESSAGES_SMS_EMAIL__
if (g_msg_cntx.send_type == SEND_CASE_SEND_EMAIL)
{
mmi_ucs2_n_to_asc((S8*) PhbNum, (S8*) g_msg_cntx.smsEmailAddress, mmi_ucs2strlen(g_msg_cntx.smsEmailAddress) * ENCODING_LENGTH);
}
#endif /* __MMI_MESSAGES_SMS_EMAIL__ */
}
#endif /* __MMI_UNIFIED_MESSAGE__ */
}
#ifdef __MMI_MESSAGES_SMS_EMAIL__ // 发送电子邮件宏
if (g_msg_cntx.send_type == SEND_CASE_SEND_EMAIL)
{
mmi_msg_send_msg_req((U8*) PhbNum, MMI_FRM_SMS_INVALID_INDEX, 0);
}
else
#endif /* __MMI_MESSAGES_SMS_EMAIL__ */
{
// 最终程序将进入该分支
// mmi_msg_send_msg_req:发送消息请求
mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, MMI_FRM_SMS_INVALID_INDEX, 0);
}
}
文中黑体字部分为笔者自己的理解,不当之处请大家恳请指正,谢谢。