Abstract: Last section we understand the main operations of SMS in Symbian OS, such as new construction, modification, and delete, this article we mainly know about SMS transmission. Send SMS may have worked in most people, simply edit a piece of text, then select one or more target numbers, click to send everything OK. This is actually the steps implemented in the program, but we need to understand more knowledge. Old method, let's first understand some of the necessary classes: csmssettings set the attribute class csmsheadersmsmsmsMs service of the SMS service, mainly related to the various parameters of the message, of course, the above CSMSSettings closely related to the SMS class is roughly Introduced, here do not repeat the description, then we will use some specific source code to analyze. First, we need to create a new SMS and get the number of acceptor. These two steps can refer to the content of the previous section, and in detail how to create new SMS in detail. Then you want to set some of the parameter information before sending, and choose to do some corresponding operations.
-------------------------------------------------- ------------------------------------- / / IMTM is set to set tmsventry msventry = iMTM-> entry () in the new SMS phase (). entry (); // Get SMS content crichtext & mtmbody = iMTM-> body (); mtmbody.reset (); mtmbody.insertl (0, KGDSMSTAG); // Insert our SMS sign // Reset TMSVENTRY MSVENTRY.IDetails.Set (IRecipient-> des ()); // set recipient info in details msventry.setinpreparation (Efalse); // set INPREPARATION TO FALSE msvEntry.SetSendingState (KMsvSendStateWaiting); // set the sending state (immediately) msvEntry.iDate.HomeTime (); // set time to Home Time // use CSmsClientMtm handling sms CSmsClientMtm * smsMtm = sTATIC_CAST (CSmsClientMtm *, iMtm); smsMtm-> RestoreServiceAndSettingsL (); // CSmsHeader sms message encapsulating a parameter, such as the service center number and transmission setting CSmsHeader & header = smsMtm-> SmsHeader (); // CSmsSettings class is used to set detailed sms header CSmsSettings * sendOptions = CSmsSettings :: Newl (); Cleanupstack :: Pushl (SendOptions); SendOptions-> COPYL (SMSMT M-> ServiceSettings (); sendOptions-> setdelivery; // Set immediately send header.setsMsSettingsl (* sendOptions); // Check the service center number validation if (header.Message (). serviceCenteraddress (). Length () == 0) {// If there is no setting, look for the default center number csmssettings * serviceTings = & (smsmtm-> serviceSettings ()); // The center number list is empty if (! ServiceSettings-> numscaddresses () {// Error message Ieikonenv-> Infowinl ("No Service Center Number"), _ L ("Cannot Send this one.");} Else {// Set to the default service center number csmsnumber * sc = 0 SC = & (ServiceSettings-> Scaddress (serviceSettings-> defaultsc ()));
Header.Message (). setServiceCenteraddressl (sc-> address ());}} cleanupstack :: popandDestroy (); ... ...
CMSventrySelection * Selection = new (Eleave) CMSventrySelection; cleanupstack :: pushl (selection); selection-> appendl (mov); // Add We want to send SMS, MoveDID is defined in the omission part, is TMSVID type variable // call This function is used to send, the specific code is described later, setscheduledsendingStatel (Selection); cleanupstack :: popandDestroy (); // selection return etrue; // here SMS has been sent ----------- -------------------------------------------------- -------------------------------------------------- -------------------------------------------------- ------------------------------------- void ... :: setscheduledsendingstatel (cmsventryselection * help) { CBASEMTM * SMSMTM = IMTM; // Add entry to task list TBUF8 <1> DummyParams; ccommandabsorBingControl :: newlc (); cmsvoperationWait * Waiter = cmsvoperationWait :: newlc (); waiter-> start (); // This function is key CMSVOPERATION * OP = SMSMTM-> InvokeAsyncFunctionL (esmsmtmcommandschedulecopy, * aSELECTION, DummyParams, Waiter-> iStatus); Cleanupstack :: Pushl (OP); CACTIVESCHEDULER :: Start (); // Start Time Wat Task Cleanupstack :: PopandDestroy (3); // Waiter, Op, CCommandabsorBingControl} -------------------------------- -------------------------------------------------- ---------------------------------
It is necessary to note that most of the operations in the process of sending SMS are used to set parameters when sending SMS, so things are trivial; if you want to achieve this part, give you suggestions try to use one A relatively universal method, there is no need to set some information that makes people who are invasive. The main role in the transmission SMS or the CBASEMTM class, this class, and the class that it inherits is responsible for the specific transmission of SMS, so the end point of the entire process must be used to implement the functions of these classes, like the above INVOKEASYNCFUNCTIONL function. .
Source Click Download Click here >>>