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