harvester/client/inc/harvesterrequestactive.h
changeset 0 c53acadfccc6
child 1 acef663c1218
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Active object for an asynchronous thumbnail request
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef HARVESTERREQUESTACTIVE_H
       
    20 #define HARVESTERREQUESTACTIVE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "harvesterclient.h"
       
    25 #include "harvestercommon.h"
       
    26 
       
    27 class CHarvesterRequestQueue;
       
    28 
       
    29 /**
       
    30  *  Active object for an asynchronous harvest request.
       
    31  *
       
    32  *  @since S60 v5.0
       
    33  */
       
    34 NONSHARABLE_CLASS( CHarvesterRequestActive ): public CActive
       
    35     {
       
    36 public:
       
    37 
       
    38     /**
       
    39      * Destructor
       
    40      *
       
    41      * @since S60 v5.0
       
    42      */
       
    43     virtual ~CHarvesterRequestActive();
       
    44 
       
    45     /**
       
    46      * Two-phased constructor
       
    47      *
       
    48      * @since S60 v5.0
       
    49      * @param aClient Session used.
       
    50      * @param aObserver Observer to receive notifications about completed
       
    51      *                  operations.
       
    52      * @param aService service to call for
       
    53      * @param aUri         Uri of the file to be harvested.
       
    54      * @param aAlbumIds  If the harvested file is to be added to some albums, 
       
    55      *                               the IDs of these albums..
       
    56      * @param aAddLocation   Defines if locationdata is to be added to the harvested item.
       
    57      * @param aQueue Queue for harvester calls
       
    58      * @return New CHarvesterRequestActive object.
       
    59      */
       
    60     static CHarvesterRequestActive* NewL( 
       
    61             RHarvesterClient& aClient, MHarvestObserver* aObserver,
       
    62             TInt aService, const TDesC& aUri, 
       
    63             HBufC8* aAlbumIds, TBool& aAddLocation,
       
    64             CHarvesterRequestQueue* aQueue );
       
    65 
       
    66     /**
       
    67      * Start harvesting
       
    68      *
       
    69      * @since S60 v5.0
       
    70      */
       
    71     void Start();
       
    72     
       
    73     /**
       
    74      * Forces the harvesting request to be sent to server immidiately
       
    75      *
       
    76      * @since S60 v5.0
       
    77      */
       
    78     void ForceHarvest();
       
    79 
       
    80 
       
    81     /**
       
    82      * Is request completed
       
    83      *
       
    84      * @since S60 v5.0
       
    85      */
       
    86     TBool RequestCompleted() const;
       
    87 
       
    88 private:
       
    89 
       
    90     /**
       
    91      * C++ default constructor
       
    92      *
       
    93      * @since S60 v5.0
       
    94      * @param aClient Session used.
       
    95      * @param aObserver Observer to receive notifications about completed
       
    96      *                  operations.
       
    97      * @param aService service to call for
       
    98      * @param aUri         Uri of the file to be harvested.
       
    99      * @param aAlbumIds  If the harvested file is to be added to some albums, 
       
   100      *                               the IDs of these albums..
       
   101      * @param aAddLocation   Defines if locationdata is to be added to the harvested item.
       
   102      * @param aQueue Queue for harvester calls
       
   103      * @return New CHarvesterRequestActive object.
       
   104      */
       
   105     CHarvesterRequestActive( RHarvesterClient& aClient,
       
   106             MHarvestObserver* aObserver, TInt aService, const TDesC& aUri, 
       
   107             HBufC8* aAlbumIds, TBool& aAddLocation,
       
   108             CHarvesterRequestQueue* aQueue );
       
   109 
       
   110     /**
       
   111      * Handles an active object's request completion event.
       
   112      *
       
   113      * @since S60 v5.0
       
   114      */
       
   115     void RunL();
       
   116 
       
   117     /**
       
   118      * Handles a leave occurring in the request completion event handler
       
   119      * RunL().
       
   120      *
       
   121      * @since S60 v5.0
       
   122      * @param aError The leave code.
       
   123      * @return Error code.
       
   124      */
       
   125     TInt RunError( TInt aError );
       
   126 
       
   127     /**
       
   128      * Implements cancellation of an outstanding request.
       
   129      *
       
   130      * @since S60 v5.0
       
   131      */
       
   132     void DoCancel();
       
   133 
       
   134 private:
       
   135     // data
       
   136 
       
   137     /**
       
   138      * Session. Ref.
       
   139      */
       
   140     RHarvesterClient& iClient;
       
   141 
       
   142     /**
       
   143      * Observer to receive notifications about completed operations. Not owned.
       
   144      */
       
   145     MHarvestObserver* iObserver;
       
   146     
       
   147     TInt iService;
       
   148     
       
   149     /**
       
   150      * Request parameters.
       
   151      */
       
   152     TFileName iUri;
       
   153     
       
   154     // Own.
       
   155     HBufC8* iAlbumIds;
       
   156 
       
   157     TBool iAddLocation;
       
   158     
       
   159     // not own
       
   160     CHarvesterRequestQueue* iRequestQueue;
       
   161     
       
   162     TPckg<TBool> iLocation;
       
   163     
       
   164     TIpcArgs iPersistentArgs;
       
   165     
       
   166     /**
       
   167      * Error code.
       
   168      */
       
   169     TInt iError;
       
   170 
       
   171     /**
       
   172      * If set, this request object can be deleted.
       
   173      */
       
   174     TBool iRequestCompleted;
       
   175 };
       
   176 
       
   177 #endif // HARVESTERREQUESTACTIVE_H
       
   178 
       
   179 
       
   180 
       
   181 // INLINE FUNCTIONS
       
   182 
       
   183 inline TBool CHarvesterRequestActive::RequestCompleted()const
       
   184     {
       
   185     return iRequestCompleted;
       
   186     }
       
   187