You Are Here:

Community: Wiki

This page was last modified on 16 June 2009, at 11:06.

CS001415 - Deleting an incoming SMS message

From Forum Nokia Wiki



ID CS001415 Creation date June 9, 2009
Platform S60 3rd Edition
S60 5th Edition
Tested on devices Nokia 5800 XpressMusic
Category Symbian C++ Subcategory Messaging


Keywords (APIs, classes, methods, functions): CMsvSession, CMsvEntry, TMsvId

Overview

This snippet demonstrates how to delete an incoming SMS message from the inbox folder.


MMP file

The following libraries and capabilities are required:

CAPABILITY   ReadUSerData WriteUserData UserEnvironment
LIBRARY msgs.lib
LIBRARY smcm.lib
LIBRARY gsmu.lib


Header file

#include <e32base.h>
#include <msvapi.h> // MMsvSessionObserver
#include <msvids.h> // Folder Ids
#include <smut.h> // KUidMsgTypeSMS
 
 
class CYourSmsEngine : public CBase
 
{
public:
static CYourSmsEngine* NewL();
static CYourSmsEngine* NewLC();
virtual ~CYourSmsEngine();
 
private:
void HandleSessionEventL(TMsvSessionEvent aEvent,
TAny* aArg1, TAny* aArg2, TAny* aArg3);
 
private:
void ConstructL();
CYourSmsEngine();
 
private:
 
// Message body
TBuf<KSmsMessageLength> iMessage;
 
// Address (phonenumber)
TBuf<KAddressLength> iAddress;
 
// Session with the messaging server
CMsvSession* iMsvSession;
 
// CMsvEntry accesses and acts upon a particular Message Server entry
CMsvEntry* iMsvEntry;
 
// Id of a new message
TMsvId iNewMessageId;
};


Source file

#include "cyoursmsengine.h"
 
#ifdef __WINS__
const TMsvId KObservedFolderId = KMsvDraftEntryId;
#else
const TMsvId KObservedFolderId = KMsvGlobalInBoxIndexEntryId;
#endif
 
const TMsvId KInbox = KMsvGlobalInBoxIndexEntryId;
 
 
CYourSmsEngine* CYourSmsEngine::NewL()
{
CYourSmsEngine* self = NewLC();
CleanupStack::Pop(self);
return self;
}
 
CYourSmsEngine* CYourSmsEngine::NewLC()
{
CYourSmsEngine* self = new (ELeave) CYourSmsEngine();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
 
void CYourSmsEngine::ConstructL()
{
// SMS automatic receiving needs a session to the messaging server
iMsvSession = CMsvSession::OpenAsyncL(*this);
}
 
CYourSmsEngine::CYourSmsEngine()
{
}
 
CYourSmsEngine::~CYourSmsEngine()
{
delete iMsvEntry;
 
if (iMsvSession)
iMsvSession->Cancel();
 
delete iMsvSession;
}
 
 
void CYourSmsEngine::HandleSessionEventL(
TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
{
switch (aEvent)
{
case EMsvServerReady:
{
// Initialise iMsvEntry
if (!iMsvEntry)
{
iMsvEntry = CMsvEntry::NewL(*iMsvSession, KInbox,
TMsvSelectionOrdering());
}
break;
}
case EMsvEntriesCreated:
{
// Only look for changes in the Inbox
if (aArg2 && *(static_cast<TMsvId*>(aArg2)) == KObservedFolderId)
{
CMsvEntrySelection* entries =
static_cast<CMsvEntrySelection*>(aArg1);
if( entries->Count() >= 1 )
iNewMessageId = entries->At(0);
else
return;
}
break;
}
case EMsvEntriesChanged:
{
// Look for changes. When using the emulator
// observed folder is drafts, otherwise inbox
if (aArg2 && *(static_cast<TMsvId*>(aArg2)) == KObservedFolderId)
{
CMsvEntrySelection* entries =
static_cast<CMsvEntrySelection*>(aArg1);
if(!entries && entries->Count() < 1 )
{
return;
}
else if (iNewMessageId == entries->At(0))
{
if( !iMsvEntry )
return;
 
// Set entry context to the new message
iMsvEntry->SetEntryL(iNewMessageId);
 
// Check the type of the arrived message and
// that the message is complete
// Only SMS's are our consern
if (iMsvEntry->Entry().iMtm != KUidMsgTypeSMS ||
!iMsvEntry->Entry().Complete())
return;
 
// Delete message from this Inbox-folder
iMsvEntry->DeleteL(iMsvEntry->EntryId());
}
}
break;
}
}
}


Postconditions

The incoming SMS message is deleted.


See also

CS001381 - Listening for incoming SMS messages

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fSeriesE5f60E25E457E25ACE25ACE25E454E25B8E2589E25E457E2589E2588E25E454E25B8E258AE25E456E258FE2590E25E455E258FE2596E25E456E25B6E2588E25E456E2581E25AFE25E457E259AE2584E25E459E2599E2584E25E454E25BBE25B6X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZmessagingQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxmessagingX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ
User Rating: qfnZuserE5FratingQNx3E2E0000X