Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 12:22, 22 March 2008.

How to get the count of recent missed calls

From Forum Nokia Wiki


ID   Creation date March 20, 2008
Platform S60 3rd, S60 3rd FP1 Tested on devices N73, N95 8Gb
Category Symbian C++ Subcategory Calls
Keywords: Recent missed calls

Overview

The original article is in Russian. You can find it here.


You can use class CMissedCallCalc for getting the count of recent missed calls and for tracking appearance of new missed calls.

As all active objects, this class emulates final state machine ( method RunL() ). The set of states is defined in enum TState.

This class uses the Log Engine. Asynchronous method NotifyChange() of class CLogEngine is used for notify about new changes. When the new changes has occured in database - RunL() called. Class CLogViewRecent is used for further asynchronous reading log.

Main methods:

  • Count() - returns count of the new recent calls
  • IsCalcCompleted() - returns check result (calculation is completed or not)

Header File

#include <e32base.h>
#include <logcli.h>
#include <logview.h>
 
const TInt KTimeDelay = 1000000; // minimum timeout for notification request
 
class CMissedCallCalc : public CActive
{
   enum TState
   {
      EWaitingChange = 1,
      EReadingLog,      
      EReadingLogItems
   };
 
   public:
      static CMissedCallCalc* NewL(); // factory
      ~CMissedCallCalc();
 
      inline TInt Count() { return iCount; } // missed call count
      inline TBool IsCalcCompleted() { return iState == EWaitingChange; } // if true - then Count() returns final value
 
   protected:
      CMissedCallCalc();
      void ConstructL();
 
      void GetLatestL();
      void StartL();
      void DoCancel();
      void RunL();
 
   private:
      TInt iCount;   // current count of the missed calls
      TState iState; // current state
 
      CLogClient* iLogClient;
      CLogViewRecent* iRecentLogView;
      RFs iFsSession;
};

Source File

#include "callCalc.h"
 
CMissedCallCalc* CMissedCallCalc :: NewL()
{
   CMissedCallCalc* self = new (ELeave) CMissedCallCalc();
   CleanupStack :: PushL( self );
   self->ConstructL();
   CleanupStack :: Pop(self);
   return self;
}
 
 
CMissedCallCalc :: CMissedCallCalc(): CActive( CActive :: EPriorityStandard )
{
}
 
CMissedCallCalc :: ~CMissedCallCalc()
{
   Cancel();
 
   delete iRecentLogView;
   iRecentLogView = NULL;
 
   delete iLogClient;
   iLogClient = NULL;
	
   iFsSession.Close();
}
 
 
void CMissedCallCalc :: ConstructL()
{	
   CActiveScheduler :: Add( this );
	
   User::LeaveIfError( iFsSession.Connect() );
	
   iLogClient = CLogClient :: NewL( iFsSession );
   iRecentLogView = CLogViewRecent :: NewL( *iLogClient );
 
   GetLatestL();		
}
 
void CMissedCallCalc :: DoCancel()
{
   if( iRecentLogView )
      iRecentLogView->Cancel();
	
   if( iLogClient )
   {
      if( iState == EWaitingChange )
         iLogClient->NotifyChangeCancel();
      else
         iLogClient->Cancel();
   }
}
 
void CMissedCallCalc :: RunL()
{
   if( iStatus != KErrCancel )
      switch( iState )
      {
         case EWaitingChange: // new event
            GetLatestL();
            break;
 
         case EReadingLog: // start reading log events from last to first 
            if( iRecentLogView->CountL() > 0 )
            {	
               iCount = 0; // clear  value
               iState = EReadingLogItems;
               if( iRecentLogView->LastL( iStatus ) ) // to last event
                  SetActive();
               else
                  StartL();
            }
            else
               StartL();
            break;
 
 
         case EReadingLogItems: // reading event
            if( iStatus == KErrNone && iRecentLogView )
            {
               TLogFlags iFlags = iRecentLogView->Event().Flags(); 
               if( !( iFlags & KLogEventRead ) ) 
                  iCount ++; // event is unread - inc value
               if( iRecentLogView->PreviousL( iStatus ) ) // try to read prev. event
                  SetActive();
               else
                  StartL();
            }
            else
               StartL();	
            break;
 
         default:
            StartL();
            break;
      }	
}	
 
 
void CMissedCallCalc :: StartL()
{
   if( iRecentLogView )
      iRecentLogView->Cancel();
		
   iLogClient->Cancel();
			
   iState = EWaitingChange;
   iLogClient->NotifyChange( TTimeIntervalMicroSeconds32( KTimeDelay ), iStatus );
   SetActive();
}
 
void CMissedCallCalc :: GetLatestL()
{
   iState = EReadingLog;
   iRecentLogView->Cancel();
   if( iRecentLogView->SetRecentListL( KLogRecentMissedCalls, iStatus ) )
      SetActive();
   else
      StartL();
}

Internal Links

Related Discussions
Thread Thread Starter Forum Replies Last Post
Can I get the count of bitmaps of MBM file? sungrass General Symbian C++ 4 2006-07-21 10:38
conditional expression of type 'class RArray<int>' is illegal ??? advocatee General Symbian C++ 5 2004-03-18 07:45
E32User-CBase 46 kamalsinghania General Symbian C++ 4 2005-03-02 18:46
Problem Receiving Calls with 6210 febemasa PC Suite API and PC Connectivity SDK 0 2002-06-26 22:10
error E32USER-CBase. Tanya Symbian User Interface 2 2007-05-07 15:05
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX