PECengine/JanitorPlugin2/Src/CPEngContactMapper.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Janitor's plugin main class. Implements most of the Janitor logic.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __CPENGCONTACTMAPPER_H__
       
    21 #define __CPENGCONTACTMAPPER_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <cntdef.h>
       
    26 #include <cntdbobs.h>
       
    27 #include <MPEngNWSessionSlotObserver2.h>
       
    28 
       
    29 #include "MPEngContactMapper.h"
       
    30 
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class   CPEngContact;
       
    34 class   CContactDatabase;
       
    35 class   CContactChangeNotifier;
       
    36 class   CPEngListObserver;
       
    37 class   CPEngNWSessionSlotID2;
       
    38 
       
    39 // CLASS DECLARATION
       
    40 /**
       
    41 *  Janitor plugIn main class
       
    42 *  It does the mapping of the contact id to the wv ids
       
    43 *
       
    44 *  @lib PEngJanitor2
       
    45 *  @since 3.0
       
    46 */
       
    47 NONSHARABLE_CLASS( CPEngContactMapper )
       
    48         : public CBase,
       
    49         public MPEngContactMapper,
       
    50         public MContactDbObserver,
       
    51         public MPEngNWSessionSlotObserver2
       
    52     {
       
    53 public:  // Constructors and destructor
       
    54 
       
    55     /**
       
    56      * Two-phased constructor.
       
    57      */
       
    58     static CPEngContactMapper* NewL();
       
    59 
       
    60     /**
       
    61      * Two-phased constructor.
       
    62      */
       
    63     static CPEngContactMapper* NewLC();
       
    64 
       
    65     /**
       
    66      * Destructor.
       
    67      */
       
    68     virtual ~CPEngContactMapper();
       
    69 
       
    70 public: // new from MPEngContactMapper
       
    71 
       
    72     /**
       
    73      *  Map wv id to the contact db id
       
    74      *
       
    75      *  @see MPEngContactMapper
       
    76      *  @since 3.0
       
    77      */
       
    78     CContactIdArray* MapWvIdToContactIdLC( const TDesC& aWVId );
       
    79 
       
    80 
       
    81 public: // new from MContactDBObserver
       
    82 
       
    83     /**
       
    84      * Handle Contact Database event
       
    85      *
       
    86      * @since 3.0
       
    87      * @param aEvent contact database event
       
    88      * @return
       
    89      */
       
    90     void HandleDatabaseEventL( TContactDbObserverEvent aEvent );
       
    91 
       
    92 public: // new from MPEngNWSessionSlotObserver2
       
    93 
       
    94     /**
       
    95      * NWSessionSlot change handler.
       
    96      *
       
    97      * @see MPEngNWSessionSlotObserver2
       
    98      * @since 3.0
       
    99      */
       
   100     void HandleNWSessionSlotChangeL(
       
   101         CPEngNWSessionSlotNotifier2& aNotifier,
       
   102         CPEngNWSessionSlotEvent2& aEvent );
       
   103 
       
   104 
       
   105     /**
       
   106      * Notification failure handler.
       
   107      *
       
   108      * @see MPEngNWSessionSlotObserver2
       
   109      * @since 3.0
       
   110      */
       
   111     void HandleNWSessionSlotError(
       
   112         TInt aError,
       
   113         CPEngNWSessionSlotNotifier2& aNotifier );
       
   114 
       
   115 private:
       
   116 
       
   117     /**
       
   118      *  Inserts new contact to the contact db cache
       
   119      *
       
   120      *  @since 3.0
       
   121      *  @param aContactId Contact Database Item Id
       
   122      *  @return KErrNone if successful, otherwise system wide error
       
   123      */
       
   124     void AddContactL( TContactItemId& aContactId );
       
   125 
       
   126     /**
       
   127      *  Remove contact from contact db cache
       
   128      *
       
   129      *  @since 3.0
       
   130      *  @param aContactId Contact Database Item Id
       
   131      *  @return KErrNone if successful, otherwise system wide error
       
   132      */
       
   133     void RemoveContactL( TContactItemId& aContactId );
       
   134 
       
   135     /**
       
   136      *  Update content of the contact in  contact db cache
       
   137      *
       
   138      * @since 3.0
       
   139      * @param aContactId Contact Database Item Id
       
   140      */
       
   141     void UpdateContactL( TContactItemId& aContactId );
       
   142 
       
   143     /**
       
   144      *  More changes happened in the contact db
       
   145      *
       
   146      *  @since 3.0
       
   147      */
       
   148     void HandleMultipleChangesL();
       
   149 
       
   150     /**
       
   151      *  Notify all list observers about wv Ids mapping change
       
   152      *
       
   153      *  @since 3.0
       
   154      *  @param aWVId wv id to update mapping
       
   155      *  @param aContactIds contact ids mapped to the wv id
       
   156      */
       
   157     void UpdateMappingOnContactListsL(
       
   158         const TDesC& aWVId,
       
   159         const CContactIdArray* aContactIds );
       
   160 
       
   161 
       
   162     /**
       
   163       * Rebuild contact db cache
       
   164       *
       
   165       * @since 3.0
       
   166       */
       
   167     void RebuildContactDbCacheL();
       
   168 
       
   169 
       
   170     /**
       
   171      *  Find Contact in contact cache
       
   172      *
       
   173      *  @since 3.0
       
   174      *  @param contact db Id
       
   175      *  @return index in array or KErrNotFound
       
   176      */
       
   177     TInt FindContact( TContactItemId& aContactId ) const;
       
   178 
       
   179 
       
   180     /**
       
   181      *  Remap given wv Ids
       
   182      *
       
   183      *  @since 3.0
       
   184      *  @param aWVIds wv ids to be remaped
       
   185      */
       
   186     void RemapWvIdsL( const MDesCArray& aWVIds );
       
   187 
       
   188 
       
   189     /**
       
   190      *  Find Contact list observer
       
   191      *
       
   192      *  @since 3.0
       
   193      *  @param aSessionId session id of desired list manager
       
   194      *  @return index in the array if found or KErrNotFound if not found
       
   195      */
       
   196     TInt FindListObserver(
       
   197         const CPEngNWSessionSlotID2& aSessionId ) const;
       
   198 private:
       
   199 
       
   200     /**
       
   201     * C++ default constructor.
       
   202     */
       
   203     CPEngContactMapper();
       
   204 
       
   205     /**
       
   206     * By default Symbian 2nd phase constructor is private.
       
   207     */
       
   208     void ConstructL();
       
   209 
       
   210 private:    // Data
       
   211 
       
   212 
       
   213     // OWN: Contact database
       
   214     CContactDatabase*                           iCntDatabase;
       
   215 
       
   216     // OWN: Contact Database Notifier
       
   217     CContactChangeNotifier*                     iCntNotifier;
       
   218 
       
   219     /// OWN: Session notifier
       
   220     CPEngNWSessionSlotNotifier2*                iSessionNotifier;
       
   221 
       
   222     /// OWN:  cached contacts
       
   223     ///       Elements OWNed
       
   224     RPointerArray<CPEngContact>                 iContacts;
       
   225 
       
   226     /// OWN: Contact list observers
       
   227     ///       Element OWNed
       
   228     RPointerArray<CPEngListObserver>            iListObservers;
       
   229 
       
   230     };
       
   231 
       
   232 #endif      // CPEngContactMapper_H
       
   233 
       
   234 // End of File