Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Observing changes in the Contacts database using Symbian C++

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

How to observer changes in the Contacts database.

Article Metadata
Compatibility
Platform(s): S60 1st Edition
S60 2nd Edition
S60 2nd Edition (initial release)
S60 1st Edition
Article
Created: User:Technical writer 2 (14 May 2003)
Last edited: lpvalente (27 Jun 2014)


Description

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;
}
}
This page was last modified on 27 June 2014, at 21:30.
55 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×