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:
|
|