Incoming Message and Missed Call Notifications

Login to reply to this topic.
Mon, 2004-12-13 11:17
Joined: 2004-05-20
Forum posts: 308
I am observing the missed calls and Incoming messages.

When there is a new message, my app gets notified of the same .But when i go to inbox and read the message , i dont get the notification . How can i get the notification for that also ??

Also i am unable to get the notification for a missed call using Log Engine ...

this is what i am doing for missed calls notifications......


Code:
CCallStatus::CCallStatus(MCallObserver* aOb):CActive(0),
iCallObserver(aOb)
{
iState=EIdle;
iLogClient=NULL;
iRecentLogView=NULL;
iFilter=NULL;
CActiveScheduler::Add(this);
}

CCallStatus::~CCallStatus()
{
Cancel();
delete iRecentLogView;
delete iFilter,
delete iLogClient;
delete iEvent;
iFsSession.Close();
// delete iCallObserver;
iCallObserver=NULL;

}

CCallStatus* CCallStatus::NewL(MCallObserver* aOb)
{
CCallStatus* self = new(ELeave) CCallStatus(aOb);
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop();
return self;
}

void CCallStatus::ConstructL()
{
User::LeaveIfError(iFsSession.Connect());
iLogClient = CLogClient::NewL(iFsSession,CActive::EPriorityStandard);
iEvent=CLogEvent::NewL();
iRecentLogView = CLogViewRecent::NewL(*iLogClient, CActive::EPriorityStandard);
iFilter = CLogFilter::NewL();
iFilter->SetEventType(KLogCallEventTypeUid);
// set the direction to incoming
//iFilter->SetDirection(_L("Missed call"));


}

void CCallStatus::GetCallStatus()
{
Start();
}


void CCallStatus::Start()
{
if(!IsActive())
{
SetState(EWaitingEvent);
iStatus = KRequestPending;
iLogClient->NotifyChange(0,iStatus);
SetActive();
}
}

void CCallStatus::RunL()
{
if(iStatus!=KErrNone)
{//success
//==================================================================
switch(iState)
{
case EWaitingEvent:
{
// iLogger.Log(KWaitingEvent);
if(!UpdateRecentView())
Start();
}
break;
case EGettingRecent:
{
// iLogger.Log(KGettingRecent);
if(!IsViewEmpty(*iRecentLogView))
{
//Failure
break;
}
else
{
//Success
const CLogEvent& event =  iRecentLogView->Event();
if (event.Description() == _L("Missed call"))
{
iCallObserver->OnCallMissed(1);
}
}

Start();
}
break;
case ENextRecent:
{
//
Start();
}
break;
case EIdle:
default:
{
SetState(EIdle);
User::Leave(KErrNotSupported);
}
}
//==================================================================
}
else
{//error
//LogEngineError(iStatus.Int());
User::Leave(iStatus.Int());
}

}

void CCallStatus::DoCancel()
{
switch(iState)
{
case EIdle:
/* nothing to do*/
break;
case EWaitingEvent:
{
iLogClient->NotifyChangeCancel();
   break;
   }
case EGettingRecent:
case ENextRecent:
{
iRecentLogView->Cancel();
break;
}
default:
break;
}
SetState(EIdle);

}

TInt CCallStatus::RunError( TInt aError )
{
return KErrNone;
}

TBool CCallStatus::IsIdle()
{
return (iState==EIdle);
}

TBool CCallStatus::UpdateRecentView()
{
TBool result = EFalse;

iStatus = KRequestPending;
TRAPD(error, result = iRecentLogView->SetRecentListL(KLogNullRecentList, *iFilter, iStatus));
result = result && (error==KErrNone);
if(result)
{
SetState(EGettingRecent);
SetActive();
// iLogger.Log(_L("[+] Updating recent view"));
}
// else
// iLogger.Log(_L("[-] No recent events to view"));

return result;
}

TBool CCallStatus::IsViewEmpty(CLogView &aView)
{
TBool result = EFalse;
TInt count = 0;

TRAPD(error, count = aView.CountL());
result = (error != KErrNone) || (count<=0);

return result;
}

void CCallStatus::SetState(TLogEngineState aState)
{
iState = aState;
}

Thanks

Amit


Tue, 2004-12-14 03:39
Anonymous (not verified)
Forum posts: 2043
Incoming Message and Missed Call Notifications
I dont understand on your 1st question. what do u want to do when u go to inbox and read the message?

But here is the example for catch incoming sms:

void CSmsReceiveHandler::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
{
 switch (aEvent)
 {
   case EMsvEntriesChanged:  // A new entry has been created in the message server
   {
     // We are interested in messages that are created in Inbox
     TMsvId* entryId = static_cast<TMsvId*>(aArg2);  // entry id from the session event
     if (*entryId == KMsvGlobalInBoxIndexEntryId)  // new entry has been created in Inbox folder
     {
       // We take the created entries into a selection
       CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
       //Process each created entry, one at a time.
       for(TInt i = 0; i < entries->Count(); i++)
       {
         MessageReceivedL(entries->At(i)); // this checks the entry and handles it if it is targeted to SMS app
       }
     }
   }
   break;
   // This event tells us that the session has been opened
   case EMsvServerReady:
     CompleteConstructL();       // Construct the mtm registry
   break;
   case EMsvCloseSession:
     // Handle close session
     iSession->CloseMessageServer();
   break;
   case EMsvServerTerminated:
     // Handle server terminated
     iSession->CloseMessageServer();
   break;
   case EMsvGeneralError:
   case EMsvServerFailedToStart:
     // A major problem has occurred
     iObserver.HandleError(MMsvObserver::EFatalServerError);
   break;
   default:
   // All other events are ignored
   break;
 }
}
Tue, 2004-12-14 05:25
Joined: 2004-05-20
Forum posts: 308
Incoming Message and Missed Call Notifications
Thnx Guest , What i mean by second question is
When a new SMS comes , i get a Small envolope on top right of the phone.
When the sms is read , the envolope goes.I.e
what i want .when the sms is read ???Basically i also want to take off that envolope when the sms is read byt thru my application .

Thanks

Amit

Thu, 2005-07-14 17:06
Joined: 2005-07-07
Forum posts: 34
Re: Incoming Message and Missed Call Notifications
Hi Amit

Are you sure that your code for missed calls catching works ?
I try to use it but I can't get recent event from log Sad

Regards Dilian
Fri, 2005-07-15 03:45
Joined: 2004-12-03
Forum posts: 276
Re: Incoming Message and Missed Call Notifications
Hi,

Quote
Basically i also want to take off that envolope when the sms is read byt thru my application .

I think it can be done by the following piece of code.... Just try it.... I hope you are getting the msvEntry and SMS mtm instance.....

Code:
msvEntry.SetUnread(EFalse);
iSmsMtm->Entry().ChangeL(msvEntry);

Dennis

Today is a gift by GOD, that's why it is called the present.

Fri, 2005-07-15 15:34
Joined: 2005-07-07
Forum posts: 34
Re: Incoming Message and Missed Call Notifications
Hi

I need from help! When I make TBool CCallStatus::UpdateRecentView() from amit's example iStatus is 0 and I can't get events from recentLog
  • Login to reply to this topic.