MTK短信开发详解(二)
[SmsMoMtGuiInterface.c]
void mmi_msg_highlight_done(void)
{
mmi_msg_highlight_generic(
STR_GLOBAL_OK,
IMG_GLOBAL_OK,
STR_GLOBAL_BACK,
IMG_GLOBAL_BACK,
mmi_msg_entry_send_option,
GoBackHistory);
[...]
}
进入[发送选项],将默认发送选项设为(仅)发送(SEND ONLY):
[SmsMoMtGuiInterface.c]
void mmi_msg_entry_send_option(void)
{
[...]
if (g_msg_cntx.sendMessageCase != SEND_CASE_SEND_FROM_OTHER_APP)
{
g_msg_cntx.sendMessageCase = SEND_CASE_SEND_ONLY; /* reset */
}
[...]
}
2.2.1、选择发送选项
以(仅)发送(SEND ONLY)为例。在高亮事件中注册ENTRY函数:
[SmsMoMtGuiInterface.c]
void mmi_msg_highlight_send_only(void)
{
#ifdef __MMI_SEND_BY_SEARCH_NAME__
[...]
#else /* __MMI_SEND_BY_SEARCH_NAME__ */
mmi_msg_highlight_generic(
STR_GLOBAL_OK,
IMG_GLOBAL_OK,
STR_GLOBAL_BACK,
IMG_GLOBAL_BACK,
mmi_msg_send_msg_to_only_entry,
GoBackHistory);
#endif /* __MMI_SEND_BY_SEARCH_NAME__ */
}
2.2.2、进入【(仅)发送】选项
[SmsMoMtGuiInterface.c]
void mmi_msg_send_msg_to_only_entry(void)
{
[...]
g_msg_cntx.msg_send_info.CurrSendSmsNumbers = 0;
g_msg_cntx.msg_send_info.TotalSendSmsNumbers = 1;
[...]
else if (g_msg_cntx.sendMessageCase != SEND_CASE_SEND_FROM_PHB)
{
memset(g_msg_cntx.smsPhoneNumber, 0, (MAX_DIGITS + 1) * ENCODING_LENGTH);
[...]
}
mmi_msg_send_msg_req((U8*) g_msg_cntx.smsPhoneNumber, MMI_FRM_SMS_INVALID_INDEX, 0);
} 2.2.3、设置短信发送请求标志
[SmsPsHandler.c]
void mmi_msg_send_msg_req(U8 *number, U16 replyindex, U8 hidenumscreen)
{
mmi_frm_sms_send_struct *sendData = OslMalloc(sizeof(mmi_frm_sms_send_struct));
memset((S8*) sendData, 0, sizeof(mmi_frm_sms_send_struct));
#ifdef __MMI_UNIFIED_MESSAGE__
if (!(mmi_um_get_current_msg_box_type() == UM_MSG_BOX_TYPE_UNSENT && GetExitScrnID() == SCR_ID_MSG_OUTBOX_OPTION))
#else
if (GetMessagesCurrScrnID() != SCR_ID_MSG_OUTBOX_SEND_OPTION)
#endif
{
sendData->sendrequire = MMI_FRM_SMS_SAVE_AFTER_FAIL; /*ML: to control if we can release EMS or not*/
}
[...]
mmi_frm_sms_send_sms(mmi_msg_send_msg_rsp, MOD_MMI, sendData);
OslMfree(sendData);
}2.3.4、注册短信发送回调函数
注册短信发送回调函数(callback, mmi_msg_send_msg_rsp), 调用短信发送预处理函
数(action, mmi_frm_sms_pre_send_sms)
[SMSCore.c]
void mmi_frm_sms_send_sms(PsFuncPtrU16 callback, module_type mod_src, mmi_frm_sms_send_struct *sendData)
{
mmi_frm_sms_send_struct *data = OslMalloc(sizeof(mmi_frm_sms_send_struct));
memcpy((S8*) data, (S8*) sendData, sizeof(mmi_frm_sms_send_struct));
mmi_frm_sms_write_action(callback, mod_src, data, mmi_frm_sms_pre_send_sms);
}
U8 mmi_frm_sms_write_action(PsFuncPtrU16 callback, module_type mod_src, void *data, PsFuncPtr function)
{
mmi_frm_sms_action_struct action;
action.mod_src = mod_src;
action.data = data;
action.callback = callback;
action.action = function;
[...]
mmi_frm_sms_action_num++;
[...]
if (mmi_frm_sms_action_curr == MMI_FRM_SMS_INVALID_NUM)
{
mmi_frm_sms_read_action();
}
return TRUE;
}
U8 mmi_frm_sms_read_action(void)
{
PsFuncPtr currFuncPtr = mmi_frm_sms_action[mmi_frm_sms_action_head].action;
void *currFuncData = mmi_frm_sms_action[mmi_frm_sms_action_head].data;
[...]
mmi_frm_sms_action_num--;
[...]
if (currFuncPtr != NULL)
{
(*currFuncPtr) (currFuncData);
}
[...]
return TRUE;
} 2.3.5、短信发送预处理
[SMSMsg.c]
void mmi_frm_sms_pre_send_sms(void *inMsg)
{
mmi_frm_sms_send_struct *sendData = (mmi_frm_sms_send_struct*) inMsg;
[...]
mmi_frm_sms_free_sendsms_data();
sendSMS = OslMalloc(sizeof(mmi_frm_sms_send_struct));
memcpy((S8*) sendSMS, (S8*) sendData, sizeof(mmi_frm_sms_send_struct));
OslMfree(sendData);
mmi_frm_sms_send_sms_req();
} 2.3.6、短信发送请求
void mmi_frm_sms_send_sms_req(void)
{
[...]
/* check SC: get SC address, inMsg keeps the flag */
if ((sendSMS->sendcheck & MMI_FRM_SMS_SC) != MMI_FRM_SMS_SC)
{
[... 首次进入 ...]
return;
}
/* check DA: show input screen, inMsg keeps the number */
if ((sendSMS->sendcheck & MMI_FRM_SMS_DA) != MMI_FRM_SMS_DA)
{
[...二次进入, 弹出号码输入框...]
else if ((strlen((S8*) sendSMS->number) == 0) && ((sendSMS->sendrequire & MMI_FRM_SMS_REPLY) == 0))
{
if (GetCurrScrnId() != SCR_ID_MSG_NUMBER)
{
mmi_frm_sms_entry_number();
}
return;
}
sendSMS->sendcheck = MMI_FRM_SMS_DA;
}
/* check validity of DA */
[...]
/* check FDL: when FDN on */
{
[...号码输入完毕, 按[确认]到此...]
[...短信内容编码...]
result = mmi_frm_sms_pack_sms();
[...绘制发送短信发送界面...]
mmi_frm_sms_entry_send();
[...设置短信发送回调...]
SetProtocolEventHandler(mmi_frm_sms_send_sms_rsp, PRT_MSG_ID_MMI_SMS_SEND_MSG_RSP);
SetProtocolEventHandler(mmi_frm_sms_abort_sms_ind, PRT_MSG_ID_MMI_SMS_SEND_ABORT_START_IND);
[...(如果是长短信,循环)发送...]
for (i = 0; i < j; i++)
{
mmi_frm_sms_send_sms_seg();
}
[...]
}
}
void mmi_frm_sms_send_sms_seg(void)
{
MMI_FRM_SMS_SEND_MSG_REQ_STRUCT *sendSms;
[...]
mmi_frm_sms_send_message(MOD_MMI, MOD_L4C, 0, PRT_MSG_ID_MMI_SMS_SEND_MSG_REQ, (oslParaType*) sendSms, NULL);
[...]
}
2.3.7、短信发送回调
无论发送是否成功(或者[取消]), 最后返回并高亮[写短信]菜单项:HighlightWMessageHandler()。
[SMSMsg.c]
void mmi_frm_sms_send_sms_rsp(void *inMsg)
{
[...]
mmi_frm_sms_callback_action((void*)number, sendResult);
[...]
}
[SmsPsHandler.c]
void mmi_msg_send_msg_rsp(void *number, module_type mod, U16 result)
{
switch (result)
{
case MMI_FRM_SMS_OK:
[... 设置跳转节点 ...]
else if (IsScreenPresent(SCR_ID_MSG_WRITE))
{
SetMessagesScrnIdToDelHistoryNodes(SCR_ID_MSG_WRITE);
}
[... 删除历史屏幕, 返回[写短信]...]
if (g_msg_cntx.msg_send_info.CurrSendSmsNumbers == g_msg_cntx.msg_send_info.TotalSendSmsNumbers)
{
DeleteMessagesHistoryNodes();
mmi_frm_sms_delete_screen_history();
}
[...]
}
} 3、收短信
3.1、短信接收过程
l4a_callbackSMSMsgSmsPsHandlerMessagesMiscell1l4c_sms_new_msg_text_lind[...]mmi_frm_sms_new_sms_ind2mmi_frm_sms_new_smsmmi_frm_sms_indicate_smsmmi_frm_sms_new_msg_ind3mmi_msg_handle_new_msg_ind4mmi_msg_new_msg_indmmi_msg_entry_new_msg_in
3.2、接收过程详解:
3.2.1、收到新短信
L4层收到短信,向MMI_Task递交消息。
[l4a_callback.c]
void l4c_sms_new_msg_text_lind(...)
{
[…]
ilm_ptr->msg_id = (kal_uint16) MSG_ID_MMI_SMS_DELIVER_MSG_IND;/* Set the message id */
// MSG_ID_MMI_SMS_DELIVER_MSG_IND被注册到mmi_frm_sms_new_sms_ind函数:↘
[SMSMsg.c]
void mmi_frm_sms_set_protocol_event_handler(void)
{
SetProtocolEventHandler(mmi_frm_sms_new_sms_ind, PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND);
[…]
}
[ProtocolEvents.h]
#define PRT_MSG_ID_MMI_SMS_DELIVER_MSG_IND MSG_ID_MMI_SMS_DELIVER_MSG_IND […]
SEND_ILM(MOD_L4C,MOD_MMI,MMI_L4C_SAP,ilm_ptr);
}
完整版本请见 http://www.51qianru.cn/bbs/
曙海教育
曙海嵌入式学院3G通信培训中心
(MTK培训,Android培训,iPhone培训)
电话:021-51875830
网址:http://www.51qianru.cn
讲师:李现路
版权所有-曙海教育 转发请注明出处