You Are Here:

Community: Wiki

This page was last modified on 15 September 2009, at 11:41.

Getting Contact Database Change Event

From Forum Nokia Wiki

Reviewer Approved   

We can receive events about contact database changes in our application, the MContactDbObserver base class must be inherited and the virtual function HandleDatabaseEventL() must be implemented. This function is called when a contact database event occurs.

If you are not familiar with Observer Pattern, please refer to [Observer Section] on Wiki.

Header required:

#include <CNTDBOBS.H> //MContactDbObserver
#include <cntdb.h> // CContactDatabase, CContactChangeNotifier

Library needed:

LIBRARY  cntmodel.lib // CContactDatabase, CContactChangeNotifier

Source code:

class CContactDatabaseObserver : public CBase, MContactDbObserver
{
 
 
public:
 
CContactDatabaseObserver();
 
// we need to override the virtual function from the base class //
 
virtual void HandleDatabaseEventL( TContactDbObserverEvent aEvent );
 
 
};
 
 
// Handle contact database events //
 
void CContactDatabaseObserver::HandleDatabaseEventL(TContactDbObserverEvent
 
aEvent)
{
switch(aEvent.iType)
{
//if any contact deleted in phonebook
case EContactDbObserverEventContactDeleted:
break;
//event if any contact changed
case EContactDbObserverEventContactChanged:
{}
break;
//event if any new contact added to phonebook
case EContactDbObserverEventContactAdded:
{}
break;
//check TContactDbObserverEventType for more events.
 
}
}
 
//We must also create the CContactChangeNotifier object to register itself to
//receive events.
 
 
CContactDatabase* ContactDatabase = CContactDatabase::OpenL();
 
// Here iContactDatabaseObserver is a CContactDatabaseObserver pointer //
 
CContactChangeNotifier* DatabaseNotifier =
CContactChangeNotifier::NewL(*ContactDatabase , this);// Changes by aamitgupta on date 5/06/2008


Related Links:

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fFileE3aMicrokernelE5fArchitectureE2eGIFX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ