Symbian3/PDK/Source/GUID-6A2160F0-6062-4E77-ABA3-B829AF9689FA.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-6A2160F0-6062-4E77-ABA3-B829AF9689FA" xml:lang="en"><title>Contacts
       
    13 database events</title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>A client application of the Contacts Server can be set to observe changes
       
    15 in the contacts database. When a change in the database occurs, the application
       
    16 gets an event. The event carries information about the type of the event,
       
    17 the contact ID, and the connection ID.</p>
       
    18 <codeblock id="GUID-F552F563-6AA7-4E55-9E0E-F131E2B2C91B" xml:space="preserve">struct TContactDbObserverEvent
       
    19     {
       
    20     TContactDbObserverEventType iType;
       
    21     TContactItemId iContactId;
       
    22     TUint iConnectionId;
       
    23     };
       
    24 </codeblock>
       
    25 <p>The following event types are defined in the <parmname>cntdbobs.h</parmname> header:</p>
       
    26 <codeblock id="GUID-9022E0A5-8CF3-469E-B1D4-2B2CC607F852" xml:space="preserve">enum TContactDbObserverEventType
       
    27     {
       
    28     EContactDbObserverEventNull,
       
    29     EContactDbObserverEventUnused,
       
    30     EContactDbObserverEventContactChanged,
       
    31     EContactDbObserverEventContactDeleted,
       
    32     EContactDbObserverEventContactAdded,
       
    33     EContactDbObserverEventUnknownChanges,
       
    34     EContactDbObserverEventRecover,
       
    35     EContactDbObserverEventRollback,
       
    36     EContactDbObserverEventTablesClosed,
       
    37     EContactDbObserverEventTablesOpened,
       
    38     EContactDbObserverEventTemplateChanged,
       
    39     EContactDbObserverEventTemplateDeleted,
       
    40     EContactDbObserverEventTemplateAdded,
       
    41     EContactDbObserverEventCurrentItemDeleted,
       
    42     EContactDbObserverEventCurrentItemChanged,
       
    43     EContactDbObserverEventOwnCardChanged,
       
    44     EContactDbObserverEventPreferredTemplateChanged,
       
    45     EContactDbObserverEventOwnCardDeleted,
       
    46     EContactDbObserverEventGroupAdded,
       
    47     EContactDbObserverEventGroupChanged,
       
    48     EContactDbObserverEventGroupDeleted,
       
    49     EContactDbObserverEventCurrentDatabaseChanged,
       
    50     EContactDbObserverEventSpeedDialsChanged
       
    51     EContactDbObserverEventSortOrderChanged,
       
    52     EContactDbObserverEventBackupBeginning,
       
    53     EContactDbObserverEventRestoreBeginning,
       
    54     EContactDbObserverEventBackupRestoreCompleted,
       
    55     EContactDbObserverEventRestoreBadDatabase,
       
    56     };
       
    57 </codeblock>
       
    58 <p>In order to make an application receive events about contact database
       
    59 changes, the <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/CNTMODEL/MContactDbObserverClass.html#%3a%3aMContactDbObserver" format="application/java-archive"><parmname>MContactDbObserver</parmname></xref> base class must be inherited and <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/CNTMODEL/MContactDbObserverClass.html#%3a%3aMContactDbObserver%3a%3aHandleDatabaseEventL%28%29" format="application/java-archive"><parmname>HandleDatabaseEventL()</parmname></xref> virtual function must be implemented.
       
    60 The function is called by the system when a contact database event occurs.</p>
       
    61 <codeblock id="GUID-EEB33DFB-0009-4CE5-BC96-41B65519F8D1" xml:space="preserve">class CMyContactObserver : public CBase, public MContactDbObserver
       
    62     {
       
    63      public:
       
    64          // any public data and functions
       
    65          CMyContactObserver ();
       
    66          // override the virtual function from the base class
       
    67          virtual void HandleDatabaseEventL( TContactDbObserverEvent aEvent );
       
    68          };
       
    69      // handling contact database events
       
    70      void CMyContactObserver::HandleDatabaseEventL( TContactDbObserverEvent aEvent )
       
    71          {
       
    72          // Event handling code
       
    73          }
       
    74 </codeblock>
       
    75 <p>In addition, the application must create the <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/CNTMODEL/CContactChangeNotifierClass.html#%3a%3aCContactChangeNotifier" format="application/java-archive"><parmname>CContactChangeNotifier</parmname></xref> object to register itself to receive events.</p>
       
    76 <codeblock id="GUID-95A974D8-3D88-4E64-8A33-AF2366C34791" xml:space="preserve">CContactDatabase* contactDb = CContactDatabase::OpenL();
       
    77 //iContactDbObserver is a CMyContactObserver pointer
       
    78 CContactChangeNotifier* notifier = CContactChangeNotifier::NewL( *contactDb, iContactDbObserver );
       
    79 </codeblock>
       
    80 </conbody></concept>