Create SMS in inbox

Source: Internet
Author: User
Tags idate

Http://discussion.forum.nokia.com/forum/showthread.php? T = 155087 & Highlight = % 2a % E6 % 94% B6 % E4 % BB % B6 % E7 % AE % B1 % 2a

// Author: liguopeng & chenxiaotian
// Aaddr [in]: addresser number
// Acontent [in]: SMS content
Void csmsmonitorengine: createnewmessagel (const tdesc & aaddr, const tdesc & acontent)
{
Const tint Len = 12;

// ================================================ ======================================
// New code
// ================================================ ======================================
Ismsmtm-> switchcurrententryl (kmsvglobalinboxindexentryid); // test!

Tmsventry newindexentry;
Newindexentry. idate. hometime ();
// The text message has not been created yet
Newindexentry. setinpreparation (etrue );
// This is an SMS message
Newindexentry. imtm = kuidmsgtypesms;
Newindexentry. itype = kuidmsvmessageentry;

Newindexentry. idetails. Set (aaddr );
Newindexentry. ide.pdf. Set (acontent. Left (LEN ));

Newindexentry. setsendingstate (kmsvsendstatenotapplicable );
Newindexentry. setunread (etrue );
Newindexentry. setnew (etrue );

// In 3rd edition crashes here if capabilities are wrong
Newindexentry. iserviceid = ismsmtm-> serviceid ();

// Pid = (tint *) & newindexentry;
/
Crichtext * richtext = crichtext: newl (ceikonenv: static ()-> systemparaformatlayerl (), ceikonenv: static ()-> systemcharformatlayerl ());
Cleanupstack: pushl (richtext );
Richtext-> insertl (0, acontent );

Csmsheader * mysmsheader = csmsheader: newl (csmspdu: esmsdeliver, * richtext );
Cleanupstack: pushl (mysmsheader );

Cmsventry * tmpentry = imsvsession-> getentryl (newindexentry. ID ());
Cleanupstack: pushl (tmpentry );
If (tmpentry-> hasstorel ())
{
Mysmsheader-> setfromaddressl (aaddr );

Cmsvstore * store = tmpentry-> editstorel ();
Cleanupstack: pushl (store );

// Set the SMS creation time. The setting in msventry is invalid.
Csmsdeliver & deliver = mysmsheader-> deliver ();
TTime nowtime;
Nowtime. hometime ();
Deliver. setservicecentertimestamp (nowtime );

Mysmsheader-> storel (* store );
Store-> storebodytextl (* richtext );

Store-> commitl ();
Cleanupstack: popanddestroy (store );
}

// You cannot save it. Otherwise, it is either a topic or a body.
// Ismsmtm-> savemessagel ();

Tmsventry tttentry = ismsmtm-> entry (). Entry ();
// Creation complete
Tttentry. setinpreparation (efalse );
// Read-only is not set, and no reply option is available for browsing in the inbox list
Tttentry. setreadonly (etrue );

Ismsmtm-> entry (). changel (tttentry );
Cleanupstack: popanddestroy (3, richtext); // tmpentry, mysmsheader, richtext

// Delete ismsmtm;
// Ismsmtm = NULL;
// Delete imtmregistry;
// Imtmregistry = NULL;
// Delete imsvsession;
// Imsvsession = NULL;

Return;
}

Http://discussion.forum.nokia.com/fo...d.php? T = 139032
A small problem was found during use, so I improved it and hoped that the cxt would be a great solution ~

Brothers who have used MTM to monitor text messages should know that when the system creates a new text message in the inbox, it usually generates two events: emsventriescreated, emsventrieschanged, in general, the example of text message monitoring is monitored strictly in this Order (the tmsvid of the new text message is saved in emsventriescreated and matched when emsventrieschanged ~
The above code generates three events when creating a new text message,
Emsventriescreated (ismsmtm-> entry (). createl (newindexentry );),
Emsventrieschanged (ismsmtm-> entry (). changel (newindexentry );),
Emsventrieschanged (ismsmtm-> entry (). changel (tttentry );),
Ismsmtm-> savemessagel () will generate csmspdu: esmssubmit text messages in the inbox, which we do not need. In order to be consistent with the new text messages created by the system, so I modified the Code:

Code:
Tmsvid csmsengine: savemessagel (csmsclientmtm & asmsmtm, const tdesc & aaddress, const tdesc & abdy, const tTime & atime) {asmsmtm. switchcurrententryl (kmsvglobalinboxindexentryid); tmsventry msventry; msventry. idate = atime; msventry. imtm = kuidmsgtypesms; msventry. itype = kuidmsvmessageentry; // in 3rd edition crashes here if capabilities are wrong msventry. iserviceid = asmsmtm. serviceid (); msventry. setinpreparation (etrue); msventry. setunread (etrue); msventry. setnew (etrue); asmsmtm. entry (). createl (msventry); tmsvid msvid = msventry. ID (); asmsmtm. switchcurrententryl (msvid); crichtext & Body = asmsmtm. body (); body. reset (); body. insertl (0, abody); csmsheader * smsheader = csmsheader: newl (csmspdu: blank, body); cleanupstack: pushl (smsheader); smsheader-> setfromaddressl (aaddress ); # ifdef eka2 // Standard Time (tTime: universaltime () tlocale locale; ttimeintervalseconds universaltimeoffset (locale. universaltimeoffset (); tint numquarterhours = universaltimeoffset. INT ()/900; # else // use the local time (tTime: hometime () for atime in version 2; tint numquarterhours (0 ); # endif smsheader-> deliver (). setservicecentertimestamp (atime, numquarterhours); cmsvstore * msvstore = asmsmtm. entry (). editstorel (); cleanupstack: pushl (msvstore); smsheader-> storel (* msvstore); // Save the information header msvstore-> storebodytextl (body ); // Save the message body msvstore-> commitl (); // submit cleanupstack: popanddestroy (2, smsheader); msventry. setreadonly (etrue); msventry. setinpreparation (efalse); msventry. idetails. set (aaddress); msventry. ide.pdf. set (abody); asmsmtm. entry (). changel (msventry); Return msvid ;}

 

Thanks for sharing

I used the time in this way.
# Ifndef _ series60_3x __
Time. hometime ();
# Else
Time. universaltime ();
# Endif

Actually, I did not find any problem in using the code from cxt. The only change you need to do is change the following line for s60 3rd edition:

Newindexentry. idate. hometime ();

====>

Newindexentry. idate. universaltime ();

Otherwise, it may cause inconsitency on e66 phone, which shows the time in the inbox list.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.