emailcontacts/remotecontactlookup/engine/inc/cpbkxrclactionservicewrapper.h
branchRCL_3
changeset 12 4ce476e64c59
parent 11 0396474f30f5
child 13 8592a65ad3fb
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
       
     2 * Copyright (c) 2008 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:  Definition of the class CPbkxRclActionServiceWrapper.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBKXRCLACTIONSERVICEWRAPPER_H
       
    20 #define CPBKXRCLACTIONSERVICEWRAPPER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 //<cmail>
       
    24 #include "fsccontactactionservicedefines.h"
       
    25 #include "mfsccontactactionserviceobserver.h"  
       
    26 //</cmail>
       
    27 #include <MVPbkContactStoreObserver.h>
       
    28 
       
    29 class CFscContactActionService;
       
    30 class TFscContactActionQueryResult;
       
    31 class CVPbkContactManager;
       
    32 class CPbkContactEngine;
       
    33 class CPbkxRclContactConverter;
       
    34 class MVPbkContactStore;
       
    35 class CPbkContactItem;
       
    36 
       
    37 /**
       
    38 * Wrapper for contact action service.
       
    39 *
       
    40 * Available actions can be queried and actions can be executed.
       
    41 *
       
    42 * Save as action is not included in queries, since it is handled
       
    43 * by ourselves.
       
    44 */
       
    45 class CPbkxRclActionServiceWrapper : 
       
    46     public CBase, 
       
    47     public MVPbkContactStoreObserver, 
       
    48     public MFscContactActionServiceObserver
       
    49     {
       
    50 public: // constructor and destructor
       
    51 
       
    52     /**
       
    53     * Constructs new object.
       
    54     *
       
    55     * @return Created object.
       
    56     */
       
    57     static CPbkxRclActionServiceWrapper* NewL( CPbkContactEngine& aContactEngine );
       
    58 
       
    59     /**
       
    60     * Destructor.
       
    61     */
       
    62     virtual ~CPbkxRclActionServiceWrapper();
       
    63 
       
    64 public: // new methods
       
    65 
       
    66     /**
       
    67     * Sets contact selector mode on or off.
       
    68     *
       
    69     * ETrue is for setting mode on, EFalse is for setting mode off.
       
    70     *
       
    71     * Queried actions depend on the given mode. This method is called only once
       
    72     * in the beginning of the execution. After calling this, SetActionMenuMode
       
    73     * is called each time when search result view or result info view is set
       
    74     * topmost. 
       
    75     *
       
    76     * @param aContactSelectorMode Contact selector mode.
       
    77     */
       
    78     void SetContactSelectorMode( TBool aContactSelectorMode );
       
    79 
       
    80     /**
       
    81     * Sets action menu mode on or off.
       
    82     *
       
    83     * ETrue is for setting mode on, EFalse is for setting mode off.
       
    84     *
       
    85     * Queried actions depend on the given mode. This method is called every 
       
    86     * time search result view or result info view is set topmost.
       
    87     *
       
    88     * @param aActionMenuMode Action menu mode.
       
    89     */
       
    90     void SetActionMenuMode( TBool aActionMenuMode );
       
    91 
       
    92     /**
       
    93     * Sets contact to contact action service.
       
    94     *
       
    95     * After setting the contact actions are queried.
       
    96     *
       
    97     * @param aContactItem Contact item.
       
    98     */
       
    99     void SetCurrentContactL( CPbkContactItem* aContactItem );
       
   100     
       
   101     /**
       
   102     * Checks whether given action is enabled by contact action service.
       
   103     *
       
   104     * @param aActionType Action type.
       
   105     * @return ETrue if action is enabled, EFalse otherwise.
       
   106     */
       
   107     TBool IsActionEnabled( const TUint64 aActionType ) const;
       
   108     
       
   109     /**
       
   110     * Executes given action.
       
   111     *
       
   112     * @param aActionType Action type.
       
   113     */
       
   114     void ExecuteActionL( const TUint64 aActionType );
       
   115 
       
   116     /**
       
   117     * Returns contact action service used by this wrapper.
       
   118     *
       
   119     * Ownership is not transferred.
       
   120     *
       
   121     * @return Contact action service.
       
   122     */
       
   123     CFscContactActionService* ActionService();
       
   124 
       
   125     /**
       
   126     * Searches for a query result of given type.
       
   127     *
       
   128     * If such is not found, NULL is returned.
       
   129     *
       
   130     * @param aType Type of result.
       
   131     * @return Query result or NULL.
       
   132     */
       
   133     const TFscContactActionQueryResult* GetResult( const TUint64 aType ) const;
       
   134 
       
   135     /**
       
   136     * Returns contact converter used by this wrapper.
       
   137     *
       
   138     * Ownership is not transferred.
       
   139     *
       
   140     * @return Contact converter.
       
   141     */    
       
   142     CPbkxRclContactConverter* ContactConverter();
       
   143     
       
   144     /**
       
   145      * Cancels action service requests.
       
   146      */
       
   147     void CancelQuery();
       
   148     
       
   149     // from base class MVPbkContactStoreObserver
       
   150     void StoreReady( MVPbkContactStore& aContactStore );
       
   151     
       
   152     void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
       
   153     
       
   154     void HandleStoreEventL( MVPbkContactStore& aContactStore, 
       
   155             TVPbkContactStoreEvent aStoreEvent );    
       
   156     
       
   157     // from base class MFscContactActionServiceObserver
       
   158     void QueryActionsComplete();
       
   159     
       
   160     void QueryActionsFailed( TInt aError );
       
   161     
       
   162     void ExecuteComplete();
       
   163     
       
   164     void ExecuteFailed( TInt aError );
       
   165     
       
   166     
       
   167 private: // constructors
       
   168 
       
   169     /**
       
   170     * Constructor.
       
   171     */
       
   172     CPbkxRclActionServiceWrapper( CPbkContactEngine& aContactEngine );
       
   173 
       
   174     /**
       
   175     * Second-phase constructor.
       
   176     */
       
   177     void ConstructL();
       
   178 
       
   179 private: // data
       
   180     
       
   181     // Contact Manger. Owned. 
       
   182     CVPbkContactManager*        iContactManager;
       
   183     // Contact Store. Not owned.
       
   184     MVPbkContactStore*          iContactStore;
       
   185     
       
   186     // Contact converter. Owned.
       
   187     CPbkxRclContactConverter*   iContactConverter;
       
   188 
       
   189     // Contact engine
       
   190     CPbkContactEngine&          iContactEngine;
       
   191     
       
   192     // Contact action service. Owned.
       
   193     CFscContactActionService*   iContactActionService;
       
   194 
       
   195     // Array to hold converted Contact item. Contains only one contact at time.
       
   196     RFscStoreContactList        iConvertedContact;
       
   197     
       
   198     // For asyncronous operation. Owned.
       
   199     CActiveSchedulerWait*       iWait;
       
   200     
       
   201     // Flag indicating whether contact selector mode is on.
       
   202     TBool                       iContactSelectorMode;
       
   203 
       
   204     // Flags used in action querying.
       
   205     TUint64                     iFlags;
       
   206 
       
   207     // Flag indicating whether we have save as contact action.
       
   208     TBool                       iSaveAsContactActionExists;
       
   209 
       
   210     // Save as contact query result.
       
   211     // We need custom implementation in search result view and this 
       
   212     // is why it is stored.
       
   213     TFscContactActionQueryResult iSaveAsContactResult;
       
   214     
       
   215     // Error code from Observer
       
   216     TInt                        iLastError;
       
   217     
       
   218     // Query flag
       
   219     TBool                       iQueryComplete;
       
   220     
       
   221     // Action execute flag
       
   222     TBool                       iExecuteComplete;
       
   223     };
       
   224 
       
   225 #endif