MTK短信开发经验本文旨在记录开发中遇到的问题和使用到的资源,方便查找和定位。文档中添加的注释和描述属于个人理解,仅供参考,请以MTK文档《MMI_DD_Messages》为准。(V2009-04-10)1、全局变量和资源短信箱容量[\custom\ps\IWIT23_07A_PMJ_BB\customer_ps_inc.h]#defineCM_SMS_MAX_MSG_NUM400//手机+SIM卡[\custom\common\PLUTO_MMI\nvram_common_defs.h]#defineNVRAM_EF_SMSAL_SMS_TOTAL200//手机信箱和索引表[\custom\common\mmi_msg_context.c]unsignedshortmmi_frm_sms_inbox_list[CM_SMS_MAX_MSG_NUM];//收件箱索引表unsignedshortmmi_frm_sms_outbox_list[CM_SMS_MAX_MSG_NUM];//发件箱索引表mmi_frm_sms_msgbox_structmmi_frm_sms_msg_box[CM_SMS_MAX_MSG_NUM];//信箱[\plutommi\mmi\miscframework\miscframeworkinc\SMSApi.h]mmi_frm_sms_app_msgbox_enum//信箱类型枚举MMI_FRM_SMS_APP_INBOX=0x02,MMI_FRM_SMS_APP_OUTBOX=0x04[\plutommi\mmi\miscframework\miscframeworkinc\SMSStruct.h]mmi_frm_sms_msgbox_enum//信箱类型枚举MMI_FRM_SMS_INBOX=0x02,MMI_FRM_SMS_OUTBOX=0x04,索引表mmi_frm_sms_inbox_list和索引表mmi_frm_sms_outbox_list,分别对应【消息】菜单中的【收件箱】和【发件箱】。信箱mmi_frm_sms_msg_box保存的只是短信副本,用于显示和其它处理,直接更改其数据对实际的短信无效,必须向L4层发送消息才能生效。通过索引列表(mmi_frm_sms_xxbox_list)在短信箱菜单和短信之间建立关联:菜单消息收件箱短信1--mmi_frm_sms_inbox_list[itemIndex]--smsIndex短信2[...]短信n短信箱(字串/屏幕)资源[plutommi\mmi\Messages\MessagesInc\MessagesResourceData.h]STR_INBOX_MENUENTRY//“收件箱”STR_OUTBOX_MENUENTRY,//“发件箱”SCR_ID_MSG_INBOX_LIST//收件箱屏SCR_ID_MSG_OUTBOX_LIST,//发件箱屏幕STR_SCR6028_CAPTION//“消息选单”2、发短信2.1、发送过程SmsMoMtGuiInterface.cSmsMoMtGuiInterfaceSmsPsHandlerSMSCoreSMSMsg1mmi_msg_highlight_done短信编辑[完成]mmi_msg_entry_send_option进入[发送选项]2mmi_msg_highlight_send_only高亮[(仅)发送]选项3mmi_msg_send_msg_to_only_entry进入[(仅)发送]选项4mmi_msg_send_msg_reqmmi_frm_sms_send_smsmmi_frm_sms_write_actionmmi_frm_sms_read_action5mmi_frm_sms_pre_send_sms6mmi_frm_sms_send_sms_reqmmi_frm_sms_send_sms_seg[......]7mmi_frm_sms_send_sms_rspmmi_msg_send_msg_rspHighlightWMessageHandler回到[写短信]菜单项2.2、发送过程详解:2.2.1、短信编辑【完成】短信编辑编辑【完成】后,按[完成]键盘进入发送选项单:[SmsMoMtGuiInterface.c]voidmmi_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);[...]}进入[发送选项],将默认发送选项设为(仅)发送(SENDONLY):[SmsMoMtGuiInterface.c]voidmmi_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、选择发送选项以(仅)发送(SENDONLY)为例。在高亮事件中注册ENTRY函数:[SmsMoMtGuiInterface.c]voidmmi_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]voidmmi_msg_send_msg_to_only_entry(void){[...]g_msg_cntx.msg_send_info.CurrSendSmsNumbers=0;g_msg_cntx.msg_send_info.TotalSendSmsNumbers=1;[...]elseif(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]voidmmi_msg_send_msg_req(U8*number,U16replyindex,U8hidenumscreen){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))#elseif(GetMessagesCurrScrnID()!=SCR_ID_MSG_OUTBOX_SEND_OPTION)#endif{sendData-sendrequire=MMI_FRM_SMS_SAVE_AFTER_FAIL;/*ML:tocontrolifwecanreleaseEMSornot*/}[...]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]voidmmi_frm_sms_send_sms(PsFuncPtrU16callback,module_typemod_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);}U8mmi_frm_sms_write_action(PsFuncPtrU16callback,module_typemod_src,void*data,PsFuncPtrfunction){mmi_frm_sms_action_structaction;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();}returnTRUE;}U8mmi_frm_sms_read_action(void){PsFuncPtrcurrFuncPtr=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);}[...]returnTRUE;}2.3.5、短信发送预处理[SMSMsg.c]voidmmi_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、短信发送请求voidmmi_frm_sms_send_sms_req(void){[...]