Summary: SMS (short message service) is part of the GSM specification. SYMBIAN OS SMS implements ETSI GSM 03.40 V7.4.0 Technical implementation based on SMS specification. (From
This specification is downloaded in http://www.etsi.org) Because our main work is mainly read, new, modified, delete, etc., so our article focuses on these operations, in the end of the article We will also simply talk about the transmission of SMS.
First, like previous articles, we briefly introduce several important classes:
CMSVSession
The 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 grasps the details of all MTMs currently available in the client, and the message client can use this class to get the DE object from CBaseMTM.
CBASEMTM
This class is mainly used to operate SMS content, such as creating, modifying SMS; specifically using code description, more detailed content You can also view the specific SDK Help.
CMSVENTRY
Equivalent to an entry of a particular message server, 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
An entry used to represent the message server is mainly used for new construction of SMS.
Let's look at a few routines :)
TMsvSelectionOrdering sort; sort.SetShowInvisibleEntries (ETrue); // sort entirety, comprising an inlet to hide // Outbox, i.e. outbox 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 You can give corresponding indextime = entry-> childdatal (entry-> AT (0)). IDate; // pop-up dialog, have the first information Receive person's number information CaknInformationNote * InformationNote = new (eleave) CaknInformationNote; InformationNote-> Executeld (entry-> at (0)). Idetails; Cleanupstack :: PopandDestroy (2);
------------------------------------------ Note: Some variables have not been introduced, For example, ISession, this is because the previous article has been 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 IDESCRIPTIONDESCRIPTION SMS content --- -------------------------------------------------- -------------------------- TPTRC IDETAILSDETAILS Send or Accepted Man No. ------------------------------------------------ -------------------------------------------------- -------------- TINT32 Ierrorrror ---------------------------------- ---------------------------------------------- Tuid IMTMMTM - -------------------------------------------------- ---------------------------- TINT32 IMTMDATA1MTM 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 IMTMDATA3MTM DATA 3: this can be used for any purpose by an mtm. ------------- -------------------------------------------------- ---------------- TMSVID IREDIDIDREL ATED Folder ID. ---------------------------------------------- -------------------------------- TMSVID ISERVICEIDSERVICE ID. -------------- -------------------------------------------------- ------------------ TINT32 Isizesize SMS size ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------------- --Tuid ITYPEENTRY TYPE --------------------------------------------- ----------------------------------- Tint32 IWDPORTNUMBERPORT NUMBER ------------ -------------------------------------------------- ------------------ TINT32 IBIOTYPEBIO Message Type -------------------------
----------------- By using the above variables, you can get all the information in the SMS. I only have introduced the few frequently used, and the rest is when you use it. It can be studied in detail. 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 userieikonenv-> infromsg (_l ("deleteall done!"); Cleanupstack :: popandDestroy (2) ;
If you have understood the operation of reading SMS information above, this whole 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-> SwitchcurrenTryl (AENTRYID); ismsmtm-> loadMsMTM-> loadMsSMTM-> loadMsSagel (); // load the message crichtext & body = ismsmtm-> body (); // SMS content save TPTRC MSG (body.read (0) WRITETOFILEL (MSG);
ISMSMTM is a pointer variable of CBasemTM type, which is of course needed, as follows: 1.ISESSION = CMSVSession :: OpenAsyncl (* this); // This function should be inherited from MMSVSessionObserver inherited anything ...... Will establish an asynchronous connection between Session Library ... // Then you can receive the event EMSVSERREADY ... / / event in the function handlesessionalEventl indicating that the call between the servers has been established ... followed by MTM Registry, and Returns SMS MTM ... 2.imtmreg = cclientmtmregistry :: newl (* iSession); 3.imtmsms = static_cast
Void WriteTOFilel (Const TPTRC & AMSG) {// Sets the storage path and file _LIT (kDirName, "// data"); _LIT (kfilename, "// system // apps // myApp //Data//msgbody.txt "); // Connect the file server and generate the corresponding folder RFS FileESession; filesession.connect (); filesession.mkdirall (kDirName); RFileWritestReam Writer; Writer.pushl (); user :: Leaveiferror (Writer.Replace (Filession, KfileName, EfileWrite); // Write the file and confirm the Writer << Amsg; Writer.commitL (); cleanupstack :: popandDestroy (); fiesession.close ();} // The following file Will use the steps above #include
TMSVENTRY NEWENTRY; NewEntry.imneWentry.ityPENEWENTRY.IMNEWENTRY.IDATE.HOMETIME (); // General Set to Current Time NEWENTRY.SETINPREPARATION (ETRUE); // Setting to True
After setting the above parameters, you can use the CBASEMTM class to complete the new operation.
CBaseMtm * iMtmSms; ... iMtmSms-> SwitchCurrentEntryL (KMsvGlobalInBoxIndexEntryId); // set inbox iMtmSms-> Entry () CreateL (newEntry);. Long smsId = newEntry.Id (); // get a new sms of idiMtmSms- > SwitchCurrenTryl (SMSID); // Sets the details of SMS_LIT (KsmsBody, "Hello World!"); Crichtext & body = imtmsms-> body (); body.Reset (); body.insertl (0, ksmsbody); NEWENTRY.IDESBRIPTION.SET (KSMSBODY); // Sets SMS's recipient or sender mobile phone number IMTMSMS-> AddadDresseel (_L ("135000000"); newntry.idetails.set (_l ("135000000")); IMTMSMS- > Entry (). Changel (newentry); // Don't forget to save imtmsms-> saveMessagel ();
In this way, you can create a new SMS. Of course, there is a new SMS experience. If you realize the information of the SMS, it is not difficult, the main steps can be divided into three steps: 1. Give some information that needs to modify SMS, such as ID, INDEX, location or other 2. Searching SMS satisfying the condition and temporarily stores these results 3. SMS information is modified using the search results. You can try it yourself!
The next content, I will continue to discuss the content of SMS with everyone, but I am looking forward to your attention! --------------------------------------------
--Kingle - 2005.1.10