remotestoragefw/webdavaccessplugin/inc/rsfwdavaccesscontext.h
changeset 0 3ad9d5175a89
equal deleted inserted replaced
-1:000000000000 0:3ad9d5175a89
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  Contexts for keeping transaction state
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CRSFWDAVACCESSCONTEXT_H
       
    20 #define CRSFWDAVACCESSCONTEXT_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 //#include <HttpErr.h>
       
    25 
       
    26 #include "rsfwremoteaccess.h"
       
    27 //#include "rsfwdavsession.h"
       
    28 #include "rsfwdavtransaction.h"
       
    29 //#include "rsfwdavfileinfo.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CRsfwDavAccess;
       
    33 //class CRsfwDirEntAttr;
       
    34 
       
    35 // CONSTANTS
       
    36 const TInt KMaxMimeTypeLength = 64;
       
    37 
       
    38 // CLASS DECLARATIONS
       
    39 
       
    40 /**
       
    41  *  WebDAV access contexts (state machines)
       
    42  *
       
    43  *  @lib davaccess.lib
       
    44  *  @since Series 60 3.1
       
    45  */
       
    46 
       
    47 class CRsfwDavAccessContext : public CBase
       
    48     {
       
    49 public: // Constructors and destructor
       
    50     /**
       
    51      * Destructor.
       
    52      */
       
    53     virtual ~CRsfwDavAccessContext();
       
    54     
       
    55 public: // New functions
       
    56      /**
       
    57      * This is used for GET and PUT operations, to allow cancelling
       
    58      * the operations by target path name (local dialog from File Manager will
       
    59      * call CancelByPath)
       
    60      * @return TDesC, the target path for the operation
       
    61      */
       
    62     virtual const TDesC& TargetPath();
       
    63 
       
    64     /**
       
    65      * Start transaction
       
    66      */
       
    67     virtual void StartL() = 0;
       
    68 
       
    69     /**
       
    70      * Receive a notification of a complete transaction
       
    71      */
       
    72     virtual void TransactionCompleteL() = 0;
       
    73     
       
    74     /**
       
    75      * Receive a notification of a failed transaction
       
    76      * @param aError error code
       
    77      */
       
    78     virtual void TransactionError(TInt aError) = 0;
       
    79    
       
    80 
       
    81     /**
       
    82      * Return the underlying WebDAV transaction
       
    83      * @return WebDAV transaction
       
    84      */
       
    85     inline CRsfwDavTransaction* WebDavTransaction()
       
    86         { return iWebDavTransaction; };
       
    87 
       
    88     /**
       
    89      * Set context id
       
    90      * @param aId id
       
    91      */
       
    92     inline void SetId(TUint aId) { iId = aId; };
       
    93 
       
    94     /**
       
    95      * Get id of the current WebDAV transaction
       
    96      * @return id
       
    97      */
       
    98     inline TUint WebDavTransactionId() { return iWebDavTransactionId; };
       
    99 
       
   100     /**
       
   101      * Get context id
       
   102      * @return id
       
   103      */
       
   104     inline TUint Id() { return iId; };
       
   105 
       
   106     /**
       
   107      * Get context status
       
   108      * @return status
       
   109      */
       
   110     inline TUint Status() { return iStatus; };
       
   111 
       
   112     /**
       
   113      * Get response handler
       
   114      * @return response handler
       
   115      */
       
   116     inline MRsfwRemoteAccessResponseHandler* ResponseHandler()
       
   117         { return iResponseHandler; };
       
   118 
       
   119     /**
       
   120      * Tell wether the context is in finished state
       
   121      * @return ETrue, if the context has finished
       
   122      */
       
   123     inline TBool Done() { return iDone; };
       
   124    
       
   125   
       
   126 protected: // New functions
       
   127     /**
       
   128      * Submit transaction
       
   129      * @return none
       
   130      */
       
   131     void SubmitL();
       
   132     
       
   133     /**
       
   134      * Retry transaction
       
   135      * @return none
       
   136      */
       
   137     void Retry();
       
   138     
       
   139     /**
       
   140      * Map HTTP error code to SymbianOS error code
       
   141      * @param aError, input and output error code
       
   142      */
       
   143     void MapError(TInt& aError);
       
   144     
       
   145 
       
   146 protected: // Data
       
   147     TUint                         iId;
       
   148     CRsfwDavAccess*                   iDavAccess;
       
   149     TUint                         iStatus;
       
   150     MRsfwRemoteAccessResponseHandler* iResponseHandler;
       
   151     CRsfwDavTransaction*           iWebDavTransaction;
       
   152     TUint                         iWebDavTransactionId;
       
   153     TBool                         iDone;
       
   154     TInt                          iTryCount;
       
   155     // allows to cancel the operation by path
       
   156     TBufC<KMaxPath>               iRemotePathName; 
       
   157 
       
   158     };
       
   159 
       
   160 // ---------------------------------------------------------------------
       
   161 // Options
       
   162 // ---------------------------------------------------------------------
       
   163 
       
   164 class CRsfwDavAccessContextOptions: public CRsfwDavAccessContext
       
   165     {
       
   166 public:
       
   167     /**
       
   168      * Two-phased constructor.
       
   169      */
       
   170     static CRsfwDavAccessContextOptions* NewL(
       
   171         CRsfwDavAccess* aDavAccess,
       
   172         MRsfwRemoteAccessResponseHandler* aResponseHandler);
       
   173 
       
   174 public: // Functions from base classes
       
   175     // From CRsfwDavAccessContext
       
   176     void StartL();
       
   177     void TransactionCompleteL();
       
   178     void TransactionError(TInt aError);
       
   179 
       
   180 private:
       
   181     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   182                     MRsfwRemoteAccessResponseHandler* aResponseHandler);
       
   183     };
       
   184 
       
   185 // -----------------------------------------------------------------
       
   186 // PropFindDir
       
   187 // -----------------------------------------------------------------
       
   188 
       
   189 class CRsfwDavAccessContextPropFindDir: public CRsfwDavAccessContext
       
   190     {
       
   191 public: // Constructors and destructor
       
   192     /**
       
   193      * Two-phased constructor.
       
   194      * 
       
   195      */
       
   196     static CRsfwDavAccessContextPropFindDir* NewL(
       
   197         CRsfwDavAccess* aDavAccess,
       
   198         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   199         const TDesC& aPathName,
       
   200         TInt aDepth,
       
   201         CRsfwDirEntAttr** aDirEntAttr,
       
   202         RPointerArray<CRsfwDirEnt>* aDirEnts);
       
   203 
       
   204     /**
       
   205      * Destructor.
       
   206      */
       
   207     virtual ~CRsfwDavAccessContextPropFindDir();
       
   208 
       
   209 public: // Functions from base classes
       
   210     // From CRsfwDavAccessContext
       
   211     void StartL();
       
   212     void TransactionCompleteL();
       
   213     void TransactionError(TInt aError);
       
   214 
       
   215 private:
       
   216     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   217                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   218                     const TDesC& aPathName,
       
   219                     TInt aDepth,
       
   220                     CRsfwDirEntAttr** aDirEntAttr,
       
   221                     RPointerArray<CRsfwDirEnt>* aDirEnts);
       
   222 private: // Data
       
   223     TInt                    iDepth;
       
   224     CRsfwDirEntAttr**           iDirEntAttr;
       
   225     RPointerArray<CRsfwDirEnt>* iDirEnts;
       
   226     RPointerArray<CRsfwDirEnt>  iOwnDirEnts;
       
   227     };
       
   228 
       
   229 // -----------------------------------------------------------------
       
   230 // PropFindFile
       
   231 // -----------------------------------------------------------------
       
   232 
       
   233 class CRsfwDavAccessContextPropFindFile: public CRsfwDavAccessContext
       
   234     {
       
   235 public:
       
   236     /**
       
   237      * Two-phased constructor.
       
   238      * 
       
   239      */
       
   240     static CRsfwDavAccessContextPropFindFile* NewL(
       
   241         CRsfwDavAccess* aDavAccess,
       
   242         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   243         const TDesC& aPathName,
       
   244         CRsfwDirEntAttr** aDirEntAttr);
       
   245 
       
   246     /**
       
   247      * Destructor.
       
   248      */
       
   249     virtual ~CRsfwDavAccessContextPropFindFile();
       
   250 
       
   251 public: // Functions from base classes
       
   252     // From CRsfwDavAccessContext
       
   253     void StartL();
       
   254     void TransactionCompleteL();
       
   255     void TransactionError(TInt aError);
       
   256 
       
   257 private:
       
   258     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   259                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   260                     const TDesC& aPathName,
       
   261                     CRsfwDirEntAttr** aDirEntAttr);
       
   262 
       
   263 private: // Data
       
   264     CRsfwDirEntAttr**           iDirEntAttr;
       
   265     RPointerArray<CRsfwDirEnt>  iOwnDirEnts;
       
   266     };
       
   267 
       
   268 // -----------------------------------------------------------------
       
   269 // Get
       
   270 // -----------------------------------------------------------------
       
   271 
       
   272 class CRsfwDavAccessContextGet: public CRsfwDavAccessContext
       
   273     {
       
   274 public:
       
   275     /**
       
   276      * Two-phased constructor.
       
   277      * 
       
   278      */
       
   279     static CRsfwDavAccessContextGet* NewL(
       
   280         CRsfwDavAccess* aDavAccess,
       
   281         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   282         const TDesC& aRemotePathName,
       
   283         const TDesC& aLocalPathName,
       
   284         TInt aOffset,
       
   285         TInt* aLength,
       
   286         TUint aFlags);
       
   287     void StartL();
       
   288     void TransactionCompleteL();
       
   289     void TransactionError(TInt aError);
       
   290 
       
   291 private:
       
   292     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   293                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   294                     const TDesC& aRemotePathName,
       
   295                     const TDesC& aLocalPathName,
       
   296                     TInt aOffset,
       
   297                     TInt* aLength,
       
   298                     TUint aFlags);
       
   299 
       
   300 private: // Data
       
   301     TBufC<KMaxPath>  iLocalPathName;
       
   302     TInt             iOffset;
       
   303     TInt*            iLength;
       
   304     TUint            iFlags;
       
   305     };
       
   306 
       
   307 // -----------------------------------------------------------------
       
   308 // Put
       
   309 // -----------------------------------------------------------------
       
   310 
       
   311 class CRsfwDavAccessContextPut: public CRsfwDavAccessContext
       
   312     {
       
   313 public:
       
   314     /**
       
   315      * Two-phased constructor.
       
   316      * 
       
   317      */
       
   318     static CRsfwDavAccessContextPut* NewL(
       
   319         CRsfwDavAccess* aDavAccess,
       
   320         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   321         const TDesC& aLocalPathName,
       
   322         const TDesC& aRemotePathName,
       
   323         const TDesC8& aMimeType,
       
   324         TInt aOffset,
       
   325         TInt aLength,
       
   326         TInt aTotalLength,
       
   327         const TDesC8* aLockToken);
       
   328 
       
   329 public: // Functions from base classes
       
   330     // From CRsfwDavAccessContext
       
   331     void StartL();
       
   332     void TransactionCompleteL();
       
   333     void TransactionError(TInt aError);
       
   334 
       
   335 private:
       
   336     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   337                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   338                     const TDesC& aLocalPathName,
       
   339                     const TDesC& aRemotePathName,
       
   340                     const TDesC8& aMimeType,
       
   341                     TInt aOffset,
       
   342                     TInt aLength,
       
   343                     TInt aTotalLength,
       
   344                     const TDesC8* aLockToken);
       
   345 
       
   346 private: // Data
       
   347     TBufC<KMaxPath>            iLocalPathName;
       
   348     TBufC8<KMaxMimeTypeLength> iMimeType;
       
   349     TInt                       iOffset;
       
   350     TInt                       iLength;
       
   351     TInt                       iTotalLength;
       
   352     const TDesC8*              iLockToken;
       
   353     
       
   354     // The recipient of the entity MUST NOT ignore any Content-*
       
   355     // (e.g. Content-Range) headers that it does not understand or implement
       
   356     // and MUST return a 501 (Not Implemented) response in such cases.
       
   357     TBool            iContentRangeSupported;
       
   358     };
       
   359 
       
   360 // -----------------------------------------------------------------
       
   361 // MkDir
       
   362 // -----------------------------------------------------------------
       
   363 
       
   364 class CRsfwDavAccessContextMkDir: public CRsfwDavAccessContext
       
   365     {
       
   366 public:
       
   367     /**
       
   368      * Two-phased constructor.
       
   369      * 
       
   370      */
       
   371     static CRsfwDavAccessContextMkDir* NewL(
       
   372         CRsfwDavAccess* aDavAccess,
       
   373         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   374         const TDesC& aPathName);
       
   375 
       
   376 public: // Functions from base classes
       
   377     // From CRsfwDavAccessContext
       
   378     void StartL();
       
   379     void TransactionCompleteL();
       
   380     void TransactionError(TInt aError);
       
   381 
       
   382 private:
       
   383     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   384                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   385                     const TDesC& aPathName);
       
   386     };
       
   387 
       
   388 // -----------------------------------------------------------------
       
   389 // Delete
       
   390 // -----------------------------------------------------------------
       
   391 
       
   392 class CRsfwDavAccessContextDelete: public CRsfwDavAccessContext
       
   393     {
       
   394 public:
       
   395     /**
       
   396      * Two-phased constructor.
       
   397      * 
       
   398      */
       
   399     static CRsfwDavAccessContextDelete* NewL(
       
   400         CRsfwDavAccess* aDavAccess,
       
   401         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   402         const TDesC& aPathName,
       
   403         TBool aIsDir,
       
   404         const TDesC8* aLockToken);
       
   405 
       
   406 public: // Functions from base classes
       
   407     // From CRsfwDavAccessContext
       
   408     void StartL();
       
   409     void TransactionCompleteL();
       
   410     void TransactionError(TInt aError);
       
   411 
       
   412 private:
       
   413     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   414                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   415                     const TDesC& aPathName,
       
   416                     TBool aIsdir,
       
   417                     const TDesC8* aLockToken);
       
   418 
       
   419 private: // Data
       
   420     TBool            iIsDir;
       
   421     const TDesC8*    iLockToken;
       
   422     };
       
   423 
       
   424 // -----------------------------------------------------------------
       
   425 // Move
       
   426 // -----------------------------------------------------------------
       
   427 
       
   428 class CRsfwDavAccessContextMove: public CRsfwDavAccessContext
       
   429     {
       
   430 public:
       
   431     /**
       
   432      * Two-phased constructor.
       
   433      * 
       
   434      */
       
   435     static CRsfwDavAccessContextMove* NewL(
       
   436         CRsfwDavAccess* aDavAccess,
       
   437         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   438         const TDesC& aSrcPathName,
       
   439         const TDesC& aDstPathName,
       
   440         TBool aOverwrite,
       
   441         const TDesC8* aSrcLockToken,
       
   442         const TDesC8* aDstLockToken);
       
   443 
       
   444 public: // Functions from base classes
       
   445     // From CRsfwDavAccessContext
       
   446     void StartL();
       
   447     void TransactionCompleteL();
       
   448     void TransactionError(TInt aError);
       
   449 
       
   450 private:
       
   451     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   452                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   453                     const TDesC& aSrcPathName,
       
   454                     const TDesC& aDstPathName,
       
   455                     TBool aOverwrite,
       
   456                     const TDesC8* aSrcLockToken,
       
   457                     const TDesC8* aDstLockToken);
       
   458 
       
   459 private: // Data
       
   460     TBufC<KMaxPath>  iSrcPathName;
       
   461     const TDesC8*    iSrcLockToken;
       
   462     const TDesC8*    iDstLockToken;
       
   463     TBool            iOverwrite;
       
   464     };
       
   465 
       
   466 // -----------------------------------------------------------------
       
   467 // Lock
       
   468 // -----------------------------------------------------------------
       
   469 
       
   470 class CRsfwDavAccessContextLock: public CRsfwDavAccessContext
       
   471     {
       
   472 public:
       
   473     /**
       
   474      * Two-phased constructor.
       
   475      * 
       
   476      */
       
   477     static CRsfwDavAccessContextLock* NewL(
       
   478         CRsfwDavAccess* aDavAccess,
       
   479         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   480         const TDesC& aPathName,
       
   481         TUint aLockFlags,
       
   482         TUint& aTimeout,
       
   483         TDesC8** aLockToken);
       
   484 
       
   485     /**
       
   486      * Destructor.
       
   487      */
       
   488     virtual ~CRsfwDavAccessContextLock();
       
   489 
       
   490 public: // Functions from base classes
       
   491     // From CRsfwDavAccessContext
       
   492     void StartL();
       
   493     void TransactionCompleteL();
       
   494     void TransactionError(TInt aError);
       
   495 
       
   496 private:
       
   497     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   498                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   499                     const TDesC& aPathName,
       
   500                     TUint aLockFlags,
       
   501                     TUint& aTimeout,
       
   502                     TDesC8** aLockToken);
       
   503 
       
   504 private: // Data
       
   505     TUint            iLockFlags;
       
   506     TUint*           iTimeout;
       
   507     TDesC8**         iLockToken;
       
   508     CRsfwDavFileInfo*    iDavFileInfo;
       
   509     };
       
   510 
       
   511 // -----------------------------------------------------------------
       
   512 // RefreshLock
       
   513 // -----------------------------------------------------------------
       
   514 
       
   515 class CRsfwDavAccessContextRefreshLock: public CRsfwDavAccessContext
       
   516     {
       
   517 public:
       
   518     /**
       
   519      * Two-phased constructor.
       
   520      * 
       
   521      */
       
   522     static CRsfwDavAccessContextRefreshLock* NewL(
       
   523         CRsfwDavAccess* aDavAccess,
       
   524         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   525         const TDesC& aPathName,
       
   526         const TDesC8* aLockToken,
       
   527         TUint& aTimeout);
       
   528     
       
   529     /**
       
   530      * Destructor.
       
   531      */
       
   532     virtual ~CRsfwDavAccessContextRefreshLock();
       
   533 
       
   534 public: // Functions from base classes
       
   535     // From CRsfwDavAccessContext
       
   536     void StartL();
       
   537     void TransactionCompleteL();
       
   538     void TransactionError(TInt aError);
       
   539 
       
   540 private:
       
   541     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   542                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   543                     const TDesC& aPathName,
       
   544                     const TDesC8* aLockToken,
       
   545                     TUint& aTimeout);
       
   546 
       
   547 private: // Data
       
   548     TBufC<KMaxPath>  iPathName;
       
   549     const TDesC8*    iLockToken;
       
   550     TUint*           iTimeout;
       
   551     CRsfwDavFileInfo*    iDavFileInfo;
       
   552     };
       
   553 
       
   554 // -----------------------------------------------------------------
       
   555 // Unlock
       
   556 // -----------------------------------------------------------------
       
   557 
       
   558 class CRsfwDavAccessContextUnlock: public CRsfwDavAccessContext
       
   559     {
       
   560 public:
       
   561     /**
       
   562      * Two-phased constructor.
       
   563      * 
       
   564      */
       
   565     static CRsfwDavAccessContextUnlock* NewL(
       
   566         CRsfwDavAccess* aDavAccess,
       
   567         MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   568         const TDesC& aPathName,
       
   569         const TDesC8* aLockToken);
       
   570 
       
   571 public: // Functions from base classes
       
   572     // From CRsfwDavAccessContext
       
   573     void StartL();
       
   574     void TransactionCompleteL();
       
   575     void TransactionError(TInt aError);
       
   576 
       
   577 private:
       
   578     void ConstructL(CRsfwDavAccess* aDavAccess,
       
   579                     MRsfwRemoteAccessResponseHandler* aResponseHandler,
       
   580                     const TDesC& aPathName,
       
   581                     const TDesC8* aLockToken);
       
   582     
       
   583 private: // Data
       
   584     const TDesC8*    iLockToken;
       
   585     };
       
   586 
       
   587 #endif // CRSFWDAVACCESSCONTEXT_H
       
   588 
       
   589 // End of File