First, like previous articles, let's briefly introduce several important classes: CMSVSESSION This class represents the client (client MTM, user interface MTM, or client message application) with the communication channel of the message server. Each client thread corresponds to an instance of such a class, and CMSVSession provides a valid way to obtain a message server message in a timely manner. A message client application must use OpenSyncl () or openasyncl () to create a session object before using any MTM or CMSventry object normally. CClientMtmRegistry Registry has mastered the details related to all MTMs currently available, and the message client can use this class to get the DE object from CBaseMTM. CBASEMTM is primarily used to operate SMS content, such as creating, modifying SMS; specifically using code descriptions, more detailed content You can also view specific SDK Help. CMSventry is equivalent to the entry of a particular message server, and current Entry is associated with its specific content. CMSventry contains two parts: First, access to this entry, different types of data can be accessed; it is running access to its sub-entry. This class is only used on the client, and the server side uses CMSVSERVERENTRY. TMSVENTRY is used to represent an entry of the message server, mainly for the new construction of SMS. First, like previous articles, let's briefly introduce several important classes: CMSVSESSION This class represents the client (client MTM, user interface MTM, or client message application) with the communication channel of the message server. Each client thread corresponds to an instance of such a class, and CMSVSession provides a valid way to obtain a message server message in a timely manner. A message client application must use OpenSyncl () or openasyncl () to create a session object before using any MTM or CMSventry object normally. CClientMtmRegistry Registry has mastered the details related to all MTMs currently available, and the message client can use this class to get the DE object from CBaseMTM. CBASEMTM is primarily used to operate SMS content, such as creating, modifying SMS; specifically using code descriptions, more detailed content You can also view specific SDK Help. CMSventry is equivalent to the entry of a particular message server, and current Entry is associated with its specific content. CMSventry contains two parts: First, access to this entry, different types of data can be accessed; it is running access to its sub-entry. This class is only used on the client, and the server side uses CMSVSERVERENTRY. TMSVENTRY is used to represent an entry of the message server, mainly for the new construction of SMS.
The following paragraphs routine is to see it TMsvSelectionOrdering sort; sort.SetShowInvisibleEntries (ETrue); // Sort the entire contents, including the hidden entrance to // set outbox, sent-mail is CMsvEntry * entry = CMsvEntry :: NewL (* iSession, KMsvGlobalOutBoxIndexEntryId , sort); cleanupstack :: Pushl (entry); // Select all content cmsventryselection * entries = entry-> childrenl (); cleanupstack :: pushl (entry); TTIME TIME; // Get the first message, At (0) ) Represents the first information, take other INDEX TIME = entry-> childdatal (entry-> at (0)). IDate; // pop-up dialog, have the first information recipient number information CaknInformationNote * InformationNote = New (ELEVE) CaknInformationNote; InformationNote-> Executeld (entry-> at (0)). Idetails; Cleanupstack :: PopandDestroy (2); ------------------------------ ---------------------------- Note: Some variables have not been introduced, such as ISession, because the previous article has mentioned! ------------------------------------------ The role of the above routine is Let everyone know how to get and operate SMS. Simply say: First define the entry of a message server, associate outbox; then remove all the SMS content in Outbox, and store the LIST pointing to the CMSventrySelection type pointer to operate the List to operate the SMS in Outbox.
Here, if you take the specific content of the single SMS, these are common variables, you can use them to get the specific details of SMS: ----------------------- -------------------
TTIME IDATE (Type and Name) Time (Description) SMS time ------------------------------------- ------------------------------------------ TPTRC IDESCRIPTION DESCRIPTION SMS content - -------------------------------------------------- ------------------------------------------------------ -------------------------------------------------- ---------------- TINT32 Irror Error ------------------------------- ------------------------------------------------ TUID IMTM MTM ------------------------------------------------ -------------------------------- Tint32 Imtmdata1 MTM Data 1: this can be used for any purpose by an mtm. - -------------------------------------------------- ----------------------------- Tint32 IMTMDATA2 MTM Data 2: this can be used for any purpose by an mtm. ---- -------------------------------------------------- -------------------------- TINT32 IMTMDATA3 MTM DATA 3: this can be used for any purpose by an mtm. ------- -------------------------------------------------- --------------------- - TMSVID IREDID RELATED Folder ID. ------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------- TMSVID ISERVICEID Service ID. ------- -------------------------------------------------- ----------------------- Tint32 isize size SMS size -------------------- -------------------------------------------------- -------- Tuid ITYPE Entry Type ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------ Tint32 iWdpportNumber Port Number ---- -------------------------------------------------- ----------------------------------------------------------------------- -
---------------------- You can get all the information in SMS by using the above variables, I only have introduced the few frequently used, the rest You can study in detail when you use it. The above routine is simple, it is also very clear, it will be more convenient to use, next to the above method we can achieve DELETE operation: TMSVSETSHOWIBLEENTRIES (ETRUE); cMsventry * entry = cmsventry :: newl (* iSession, KMsvDraftEntryId, sort); CleanupStack :: PushL (entry); CMsvEntrySelection * entries = entry-> ChildrenL (); CleanupStack :: PushL (entries); TInt i = entries-> Count (); for (TInt ncount = 0; Ncount deletel (entries-> at (ncount)); // Information to the user ieikonenv-> infromsg (_l ("deleteall done!"); Cleanupstack :: popandDestroy (2 ); If you have understood the operation of reading SMS information above, this all deletion is not difficult to understand. Different only call a deletel () function, this function is defined in class CMSventry, which can delete the SMS fixed in the fixed index location. Details You can view the relevant SDK Help has the above understanding, it is not difficult to see that the SMS operation is actually similar. Let's take a look at how to export the SMS content to the file.
Here, you will use CBASEMTM to see the following routines: ismsmtm-> switchcurrententryl; ismsmtm-> loadMessagel (); // load the message crichtext & body = ismsmtm-> body (); // SMS content save to crichtext TPTRC MSG (Body.Read (0)) in the control object; WRITETOFILEL (MSG); ISMSMTM is a pointer variable of CBaseMTM type, which is of course needed, as follows: 1.Issis = cmsvsession :: OpenAsyncl (* this); // The parameter of this function should be any class that inherited from MMSVSessionObserver ...... It will create an asynchronous connection between Session Library ... // You can receive an event EMSVSERVERREADY ... / / event in the function handlesessionEventl ... // event Arrival indicates that the call between the server has been established ... then get MTM Registry and return to SMS mtm ... 2.imtmreg = cclientmtmregistry :: newl (* iSession); 3.imtmsms = static_cast
New SMS is more complicated, we list some of the main steps: TMSventry.com; newry.imtm newentry.IDate.IMTM new refetry.idate.hometime (); // is generally set to the current time Newentry.setInpRepression (ETRUE); // After setting up the above parameters, then you can use the CBaseMTM class to complete the new operation CBaseMTM * IMTMSMS; ... imtmsms-> switchcurrenTryl (kmsvglobalinboxIndexentryid); // Set to the Recognized box IMTMSMS-> entry (). Createl (NEWENTRY); long smsid = newentry.id (); // Get new SMS ID iMTMSMS-> SwitchCurrenTryl (SMSID); // Setting the details of SMS _LIT (KsmsBody, "Hello World!"); CRICHTEXT & BODY = iMTMSMS-> body (); body.reset (); body.insertl (0, ksmsbody); newentry.IDEScription.set (ksmsbody); // Set SMS's recipient or sender mobile phone number imtmsms-> addaddresseel (_l ("13500000000"); newntry.idetails.set (_L ("135000000")); imtmsms-> entry (). Changel (newentry); // Don't forget to save iMTMSMS-> saveMessagel (); this, You can create a new SMS. Of course, there is a new SMS experience. If you implement the information to modify SMS, it is not difficult. The main steps can be divided into three steps: 1. Give some information to modify SMS, such as ID, index, Location or other 2. Search to find the SMS satisfying the condition and temporarily save SMS information modification with the search results, and finally confirm the change, you can do a detailed analysis. a bit! 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 CSMSHeader SMS header information of the SMS service, mainly related to the various parameters of the message, of course, the above CSMSSettings is closely related to the other related SMS classes in the previous section. It is generally introduced, not repeated here, then we will analyze some specific source code. 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.
Program code: // 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.setinpRepression (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-> RESTORSERVICEADSETTING (); // CSMSHeader Package SMS message parameters * sendOptions = CSmsSettings :: NewL (); CleanupStack :: PushL (sendOptions); sendOptions-> CopyL (smsMtm-> ServiceSettings ()); sendOptions-> SetDelivery (ESmsDeliveryImmediately); // set transmitted immediately 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, which is the TMSVID type variable // called this function for sending, concrete code later introducing setScheduledsendingStatel (Selection); cleanupstack :: popandDestroy (); // selection return etrue; // here sms has been sent SetScheduledSendingStateL function code is as follows: program code: void ... :: SetScheduledSendingStateL (CMsvEntrySelection * aSelection) {CBaseMtm * smsMtm = iMtm; // entry is added to the task list TBuf8 <1> dummyParams; CCommandAbsorbingControl :: NewLC ( ); CMsvOperationWait * waiter = CMsvOperationWait :: NewLC (); waiter-> Start (); // this function is the key CMsvOperation * op = smsMtm-> InvokeAsyncFunctionL (ESmsMtmCommandScheduleCopy, * aSelection, dummyParams, waiter-> iStatus); CleanupStack: : Pushl (OP); CACTIVESCHEDULER :: Start (); // Start Timetable Task Cleanupstack :: PopandDestroy (3); // Waiter, Op, CCommandabsorBingControl} Requires We note: Most of the process of sending SMS The operation is used to set the parameters when sending SMS, so things are trivial; if you want to achieve this part, give you the suggestion to use a relatively universal method, no need to set some people information. 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. . Article Source: http://symbian.org.cn/bbs/viewtopic.php? T = 882