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 09:15, 24 August 2007.

TSS000032 - Observing changes in the Contacts database

From Forum Nokia Wiki


Subject:

Observing changes in the Contacts database TSS000032

 

Platform(s): Device(s), SW version(s):
S60 1st Edition
S60 2nd Edition
N/A

Category:

Symbian C++

Subcategory:

General

Description:

Solution
This is a simplified example of the code lines needed for the Contacts observer.
// Application UI owns contact observer
class CEventsAppUi : public CEikAppUi
   {
public:
   void ConstructL();
   ~CEventsAppUi();
public:
    void HandleCommandL(TInt aCommand);
private:
   CEventsAppView* iAppView; // owns
   CEventsContacts* iContactObserver;
   };
void CEventsAppUi::ConstructL()
   {
   BaseConstructL(); // Call base constructor
   iAppView = CEventsAppView::NewL(ClientRect());
   AddToStackL(iAppView);
   // Create an observer
   iContactObserver = new(ELeave) CEventsContacts(iAppView);
   iContactObserver->ConstructL();
   }
// CEventsContacts implements MContactDbObserver interface
class CEventsContacts : public CBase, public MContactDbObserver
   {
public:
   CEventsContacts(CEventsAppView* aAppView);
   void ConstructL();
   ~CEventsContacts();
   // Override the virtual function of MContactDbObserver
   void HandleDatabaseEventL(TContactDbObserverEvent aEvent);
private:
   CContactDatabase* iContactDb;
     CContactChangeNotifier* iNotifier;
     CEventsAppView* iAppView;
     };
CEventsContacts::CEventsContacts(CEventsAppView* aAppView)
:iAppView(aAppView)
   {
   }
void CEventsContacts::ConstructL()
   {
   // Open the database
   iContactDb = CContactDatabase::OpenL();
   // Register the observer
   iNotifier = CContactChangeNotifier::NewL(*iContactDb, this);
   }
CEventsContacts::~CEventsContacts()
   {
delete iNotifier;
delete iContactDb;
 }
void CEventsContacts::HandleDatabaseEventL(TContactDbObserverEvent
aEvent)
   {
   // The changed item
   TContactItemId contactItem = aEvent.iContactId;
   switch (aEvent.iType)
      {
   case EContactDbObserverEventContactChanged:
      // Handle contact changed event
      break;
   case EContactDbObserverEventContactDeleted:
      // Handle contact deleted event
      break;
   ...
   default:
      break;
      }
   }

Creation date:

May 14, 2003

Last modified:

 
Related Discussions
Thread Thread Starter Forum Replies Last Post
What file type is nokia 6300's contact book? duhprest General Symbian C++ 2 2007-10-22 10:43
Create Database in user defined location sruthimp General Symbian C++ 1 2007-07-24 10:18
Unwanted contact template fields... ashbhatia General Symbian C++ 1 2006-10-07 10:55
using SyncML for user defined database. abhicreation OMA DM/DS/CP 6 2008-02-11 16:58
Record store problem harshalpatil Mobile Java General 8 2007-05-24 10:25
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZKnowledgeBaseContentQ
     qfnZtypeQUqfnTypeZTechnicalSolutionQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX