??Help Urgent....Showing a message on receiving an sms

Login to reply to this topic.
Fri, 2007-11-02 05:24
Joined: 2007-11-02
Forum posts: 37

Hi,
I am using s60 3rd FP1(os v9.2)
Device used:-N95

Purpose:--
I want to show a message written in .rss file of application on receiving an sms.

Status:-
1.The code compiles and builds well and installs into phone
2.But does not seem to handle incoming messages

Can some One help??????

Explanation:-
The steps I use are:-
1.Create a "Hello World" GUI application in carbide
2.Create the resource of type TBuf32 in .rss file
3.Enter the text in corresponding field of .rls file
4.instantiate "smshandler class" in "AppUi".
The SmsHandler class inherits from
->CMsvSessionObserver and
->CActive(derived from
CActive for other purposes)

5.in the ConstructL() of "smshandler class",
a.Create a session of type "CMsvSession" with the
sms Server using CMsvSession::OpenAsyncL()
b.an instace of CMsvEntrySelction (to add recceived
messages to it
later in the
application)
6.In HandlesessionEvent():-
Check for the event type in switch(aEvent) for the
events- (i)EMsvServerReady,(ii)EMsvEntriesCreated

7.There are no operations in case EmsvServerReady,

case EMsvServerReady:
break;

8.In EMsvEntriesCreated------
a.get the "TMsvId" from 2nd argument of
HandleSessionEventL() and exit if it is not equal
to KMsvGlobalInboxIndexentryId (msg not in inbox)
b.Create an "CMsvEntrySelection" object from 1st
argument of HandleSessionEvent()
c.In a for loop iterate through all entries in
current "CMsvEntrySelection" and chek if any entry
is of type "SMS"
d.Sms types are added to another "CMsvEntrySelection"
object that was created in "ConstructL()" of this
class
e.Commit Changes
f.Print a message in resource using
CAknInformationNote

Here is the related code:

void xxxSmsHandler::ConstructL(xxxAppView* aAppView,
xxxAppUi* aAppUi)
{
iSession=CMsvSession::OpenAsyncL(*this);
iSelection=new (ELeave)CMsvEntrySelection();

User::LeaveIfError( iTimer.CreateLocal() ); // Initialize timer
CActiveScheduler::Add( this ); // Add to scheduler
}

void xxxSmsHandler::HandleSessionEventL(TMsvSessionEvent aEvent,TAny* aArg1,TAny* aArg2,TAny* aArg3)
{

switch(aEvent)
{
case EMsvServerReady:

break;
case EMsvEntriesCreated:
TMsvId* entryId=STATIC_CAST(TMsvId*,aArg2);
if(*entryId!=KMsvGlobalInBoxIndexEntryId)
{
break;
}
CMsvEntrySelection* entries=STATIC_CAST(CMsvEntrySelection*,aArg1);
for(TInt i(0);iCount();i++ )
{
if(iSession->GetEntryL(entries->At(i))->Entry().iMtm==KUidMsgTypeSMS)
{
iSelection->AppendL(entries->At(i));
CMsvEntry* serverEntry = iSession->GetEntryL( entries->At(i)); // current entry
CleanupStack::PushL( serverEntry );
TMsvEntry entry = serverEntry->Entry(); // currently handled message entry

entry.SetNew( ETrue );
entry.SetUnread( ETrue );
entry.SetVisible( EFalse );

serverEntry->ChangeL( entry );
CleanupStack::PopAndDestroy();

DisplayText();
}
}

break;
default:
break;

}
}
void xxxSmsHandler::DisplayText()
{

// Load a string from the resource file and display it
HBufC* textResource = StringLoader::LoadLC( R_COMMAND1_TEXT );
CAknInformationNote* informationNote;

informationNote = new ( ELeave ) CAknInformationNote;

// Show the information Note with
// textResource loaded with StringLoader.
informationNote->ExecuteLD( *textResource);

// Pop HBuf from CleanUpStack and Destroy it.
CleanupStack::PopAndDestroy( textResource );
}


Fri, 2007-11-02 09:45
Joined: 2007-11-02
Forum posts: 37
Re: ??Help Urgent....Showing a message on receiving an sms

Hi,
I added the following lines of code (under EMsvServerReady)and get 3 errors which are also described below.

void CCamControlSmsHandler::HandleSessionEventL(TMsvSessionEvent aEvent,TAny* aArg1,TAny* aArg2,TAny* aArg3)
{

switch(aEvent)
{
case EMsvServerReady:
TMsvId ServiceId(KUidMsgTypeSMS.iUid);
TBuf8 progress;
iSession->ServiceProgress(ServiceId,progress);
_LIT8(KCompare,"KErrNone");
if(progress.Compare(KCompare))
{
iReg=CClientMtmRegistry::NewL(*iSession);
iMtm=STATIC_CAST(CSmsClientMtm*,iReg->NewMtmL(KUidMsgTypeSMS));
}
break;
case EMsvEntriesCreated:
------------
-----------
break;
}

Const TInt KBfrLength=20;

Errors:-------------

Severity and Description Path Resource Location Creation Time Id
1.error: crosses initialization of `TBuf8<20> progress' xxx/src xxxSmsHandler.cpp line 114 1193991696484 128

2.error: jump to case label xxx/src xxxSmsHandler.cpp line 123 1193991696484 127

even if I change the value of KbfrLength=400, the error does not go.

Fri, 2007-11-02 11:46
Joined: 2007-11-02
Forum posts: 37
Re: ??Help Urgent....Showing a message on receiving an sms

Wrapping curly braces solves the error

switch(aEvent)
{
case EMsvServerReady:
{
TMsvId ServiceId(KUidMsgTypeSMS.iUid);
TBuf8< KBfrLength> progress;
iSession->ServiceProgress(ServiceId,progress);
_LIT8(KCompare,"KErrNone");
if(progress.Compare(KCompare))
{
iReg=CClientMtmRegistry::NewL(*iSession);
iMtm=STATIC_CAST(CSmsClientMtm*,iReg->NewMtmL(KUidMsgTypeSMS));
}
break;
}
case EMsvEntriesCreated:
------------
-----------
break;
}

but still ,
the message of .rss file is not shown on receiving the sms.

After I install the application into mobile, I run the application.
Send an sms from another cell into my cell.
At this point I need the string declared in .rss file should be displayed.

But this does not happen..

Now I am trying to handle the EMsvEntriesChanged and EMsvEntriesMoved Events.

But I dont know much about thesse 2 event......

Is there any link..........

  • Login to reply to this topic.