ccservices/cmsservices/cmsengine/Server/inc/cmsserverxspcontacthandler.h
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2007 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: 
       
    15 *       
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CMSSERVERXSPCONTACTHANDLER__
       
    21 #define __CMSSERVERXSPCONTACTHANDLER__
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include "cmscontact.h"
       
    26 #include <VPbkEng.rsg>
       
    27 #include <badesca.h>
       
    28 #include <MVPbkBatchOperationObserver.h>
       
    29 #include <MVPbkContactFindFromStoresObserver.h>
       
    30 #include <MVPbkSingleContactOperationObserver.h>
       
    31 #include <CVPbkContactLinkArray.h>
       
    32 
       
    33 class MVPbkContactLink;
       
    34 class MVPbkStoreContact;
       
    35 class CCmsServerContact;
       
    36 class CCmsPhoneBookProxy;
       
    37 class CVPbkContactManager;
       
    38 class MVPbkContactLinkArray;
       
    39 class CCmsServerAsyncContact;
       
    40 class CCmsServerContactAttributes;
       
    41 class MPresenceTrafficLights;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 NONSHARABLE_CLASS( CCmsServerXSPContactHandler ) : public CBase,
       
    45                        public MVPbkContactFindFromStoresObserver,
       
    46                        public MVPbkSingleContactOperationObserver
       
    47     {
       
    48     public:  
       
    49         
       
    50         /**
       
    51         * Start the server thread
       
    52         * @return TInt Error code
       
    53         */
       
    54         static CCmsServerXSPContactHandler* NewL( CCmsServerContact& aContact,
       
    55                                                   CCmsServer& aCmsServer );
       
    56         
       
    57         /**
       
    58         * Start the server thread
       
    59         * @return TInt Error code
       
    60         */
       
    61         void SaveMessage( const RMessage2& aMessage );
       
    62         
       
    63         /**
       
    64         * Start the server thread
       
    65         * @return TInt Error code
       
    66         */
       
    67         TInt ContactCount() const;
       
    68         
       
    69         /**
       
    70         * Start the server thread
       
    71         * @return TInt Error code
       
    72         */
       
    73         MVPbkStoreContact* Contact( TInt aIndex ) const;
       
    74         
       
    75         /**
       
    76         * Start the server thread
       
    77         * @return TInt Error code
       
    78         */
       
    79         void Cancel();
       
    80         
       
    81         /**
       
    82         * Start the server thread
       
    83         * @return TInt Error code
       
    84         */
       
    85         virtual ~CCmsServerXSPContactHandler();
       
    86         
       
    87         void NumberOfFinds( TInt aCount );
       
    88         void NumberOfStoresInFind( TInt aStoresNumber );
       
    89         
       
    90     private:
       
    91         
       
    92         /**
       
    93         * Start the server thread
       
    94         * @return TInt Error code
       
    95         */
       
    96         CCmsServerXSPContactHandler( CCmsServerContact& aContact,
       
    97                                      CCmsServer& aCmsServer );
       
    98     
       
    99     private:  //From MVPbkContactFindFromStoresObserver
       
   100         
       
   101         /**
       
   102         * This is called when one store completes its find. If this
       
   103         * leaves then FindFromStoreFailed is called. Client takes 
       
   104         * the ownership of all results immediately!
       
   105         *
       
   106         * FindFromStoresOperationComplete is called after
       
   107         * all stores have called either this or FindFromStoreFailed.
       
   108         *
       
   109         * @param aStore    The store whose find results are available
       
   110         * @param aResultsFromStore The find results from the store.
       
   111         *                          Client takes the ownership immediately!
       
   112         */
       
   113         void FindFromStoreSucceededL( MVPbkContactStore& aStore, MVPbkContactLinkArray* aResultsFromStore );
       
   114 
       
   115         /**
       
   116         * Called when a find operation of one store fails. Doesn't stop
       
   117         * the find from other stores in the case there are multiple stores.
       
   118         *
       
   119         * @param aStore    The failed store.
       
   120         * @param aError    A system wide error code from the 
       
   121         *                  store implementation.
       
   122         */
       
   123         void FindFromStoreFailed( MVPbkContactStore& aStore, TInt aError );
       
   124 
       
   125         /**
       
   126         * This is called after all stores have called either 
       
   127         * FindFromStoreSucceed or FindFromStoreFailed. It's called 
       
   128         * also when there are no stores that offer find operation.
       
   129         */
       
   130         void FindFromStoresOperationComplete();
       
   131 
       
   132     private:  //From MVPbkSingleContactOperationObserver
       
   133 
       
   134          /**
       
   135          * Called when operation is completed.
       
   136          *
       
   137          * @param aOperation the completed operation.
       
   138          * @param aContact  the contact returned by the operation.
       
   139          *                  Client must take the ownership immediately.
       
   140          *
       
   141          *                  !!! NOTICE !!!
       
   142          *                  If you use Cleanupstack for MVPbkStoreContact
       
   143          *                  Use MVPbkStoreContact::PushL or
       
   144          *                  CleanupDeletePushL from e32base.h.
       
   145          *                  (Do Not Use CleanupStack::PushL(TAny*) because
       
   146          *                  then the virtual destructor of the M-class
       
   147          *                  won't be called when the object is deleted).
       
   148          */
       
   149         void VPbkSingleContactOperationComplete( MVPbkContactOperationBase& aOperation,
       
   150                                                  MVPbkStoreContact* aContact );
       
   151 
       
   152          /**
       
   153          * Called if the operation fails.
       
   154          *
       
   155          * @param aOperation    the failed operation.
       
   156          * @param aError        error code of the failure.
       
   157          */
       
   158         void VPbkSingleContactOperationFailed( MVPbkContactOperationBase& aOperation, TInt aError );
       
   159         
       
   160     private:  //Data
       
   161         
       
   162         TInt                                iCompletionCode;
       
   163         TBool                               iActive;
       
   164         RMessage2                           iMessage;
       
   165         CCmsServerContact&                  iServerContact;
       
   166         RPointerArray<MVPbkStoreContact>    iContactArray;
       
   167         TInt iNumberOfFinds;
       
   168         TInt iNumberOfCompletedFinds;
       
   169         CVPbkContactLinkArray* iContactLinks;
       
   170         TInt iNumberOfStoresInFind;
       
   171         TInt iNumberOfCompletedStoresInFind;
       
   172         CCmsServer& iCmsServer;
       
   173     };
       
   174 
       
   175 #endif  //__CMSSERVERXSPCONTACTHANDLER__
       
   176 
       
   177 
       
   178 // End of File