remotestoragefw/webdavaccessplugin/inc/rsfwdavtransaction.h
changeset 13 6b4fc789785b
parent 2 c32dc0be5eb4
equal deleted inserted replaced
2:c32dc0be5eb4 13:6b4fc789785b
     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:  WebDAV transaction
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CRSFWDAVTRANSACTION_H
       
    20 #define CRSFWDAVTRANSACTION_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <uri8.h>
       
    25 //#include <f32file.h>
       
    26 //#include <s32file.h>
       
    27 //#include <http/MHTTPAuthenticationCallback.h>
       
    28 #include <http/mhttpdatasupplier.h>
       
    29 //#include <chttpformencoder.h>
       
    30 #include <http/mhttptransactioncallback.h>
       
    31 
       
    32 //#include <xml/parser.h>
       
    33 
       
    34 #include "rsfwdavdefs.h"
       
    35 //#include "rsfwremoteaccess.h"
       
    36 //#include "rsfwdavsession.h"
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CRsfwDavSession;
       
    40 class CRsfwDirEnt;
       
    41 class CRsfwDavFileInfo;
       
    42 
       
    43 // CONSTANTS
       
    44 const TInt KHttpPortNumber  =  80;
       
    45 const TInt KHttpsPortNumber = 443;
       
    46 _LIT(KHttpScheme, "http");
       
    47 _LIT(KHttpsScheme, "https");
       
    48 _LIT8(KHttpsScheme8, "https");
       
    49 
       
    50 /**
       
    51  *  WebDAV transaction
       
    52  *
       
    53  *  @lib davaccess.lib
       
    54  *  @since Series 60 3.1
       
    55  */
       
    56 class CRsfwDavTransaction: public CBase,
       
    57                           public MHTTPTransactionCallback,
       
    58                           public MHTTPDataSupplier
       
    59                      
       
    60     {
       
    61 public: // Constructors and destructor
       
    62     /**
       
    63      * Two-phased constructor.
       
    64      */
       
    65     static CRsfwDavTransaction* NewL(CRsfwDavSession* aWebDavSession,
       
    66                                     TWebDavOp aWebDavOp,
       
    67                                     const TUriC8& aUri, 
       
    68                                     RStringF aMethod,
       
    69                                     TUint aTransactionId);
       
    70     /**
       
    71      * Destructor.
       
    72      */
       
    73     virtual ~CRsfwDavTransaction();
       
    74 
       
    75 public: // New functions
       
    76     void SetBodyData(HBufC8* aRequestBodyBuffer);
       
    77     void SetBodyFileL(const TDesC& aPath, 
       
    78                       TInt aOffset, 
       
    79                       TInt* aLength,
       
    80                       TUint aFlags);
       
    81     void SetPropFindPath(HBufC* aPropFindPath);
       
    82     void SetPropFindDirEntryArray(RPointerArray<CRsfwDirEnt>& aDirEnts);
       
    83     void SubmitL();
       
    84     void Cancel();
       
    85     void SetDavFileInfoL(CRsfwDavFileInfo** aDavFileInfo, const TDesC& aPath);
       
    86     inline RHTTPTransaction HttpTransaction() {return iHttpTransaction;};
       
    87     inline TUint Id() {return iTransactionId;};
       
    88     inline TInt Status() {return iStatus;};
       
    89 
       
    90 public: // Functions from base classes
       
    91     // From MHTTPTransactionCallback
       
    92     void MHFRunL(RHTTPTransaction aTransaction, 
       
    93                  const THTTPEvent& aEvent);
       
    94     TInt MHFRunError(TInt aError,
       
    95                      RHTTPTransaction aTransaction,
       
    96                      const THTTPEvent& aEvent);
       
    97     
       
    98     // From MHTTPDataSupplier
       
    99     TBool GetNextDataPart(TPtrC8& aDataPart);
       
   100     void ReleaseData();
       
   101     TInt OverallDataSize();
       
   102     TInt Reset();
       
   103 
       
   104 private:
       
   105     void ConstructL(CRsfwDavSession* aWebDavSession,
       
   106                     TWebDavOp aWebDavOp,
       
   107                     const TUriC8& aUri, 
       
   108                     RStringF aMethod,
       
   109                     TInt aTransactionId);
       
   110     void TransactionCompleteL();
       
   111     void TransactionError();
       
   112     void Cleanup();
       
   113     void PropFindResponseBeginL(TInt aDepth);
       
   114     void LockQueryResponseBegin();
       
   115     void ParsePropFindResponseL(const TDesC8& aFragment);
       
   116     void ParseLockResponseL(const TDesC8& aFragment);
       
   117     void PropFindResponseEndL();
       
   118     void LockResponseEndL();
       
   119 
       
   120 public: // data
       
   121     TWebDavOp               iWebDavOp;
       
   122     
       
   123 private: // Data
       
   124     TUint                   iTransactionId;
       
   125     CRsfwDavSession*        iWebDavSession;
       
   126     RHTTPTransaction        iHttpTransaction;
       
   127     TBool                   iMoreToCome;
       
   128     RFs                     iFs;
       
   129     
       
   130     // files used with PUT and GET 
       
   131     RFile                   iBodyFile;
       
   132     TFileName               iBodyFilePath;
       
   133     TInt                    iBodyFileOffset;
       
   134     TUint                   iBodyFileFlags;
       
   135     TParse                  iParsedBodyFilePath;
       
   136     
       
   137     // pointer to client's "length" variable
       
   138     // GET operation will set this based on "content-length" from the server
       
   139     TInt*                   iClientsLength;
       
   140 
       
   141     HBufC8*                 iRequestBodyBuffer;
       
   142 
       
   143     // PROPFIND parser needs to now where it is prop finding....
       
   144     HBufC*                  iPropFindPath;
       
   145     // PROPFIND etc: response body is copied to a memory buffer
       
   146     HBufC8*                 iResponseBuffer;
       
   147     // how much body data has been sent to the HTTP stack
       
   148     TInt                    iSendDataCount;
       
   149     // total size of body the data
       
   150     TInt                    iOverallDataSize;
       
   151     TInt                    iStatus;
       
   152     TBool iNoContentLength;
       
   153     TBool                   iDiscardBody; // there may be body that we discard
       
   154     
       
   155     // Used with LOCKs to store files lock token
       
   156     CRsfwDavFileInfo*           iDavFileInfo; 
       
   157     
       
   158     // Used with PROPFIND to store metadata of all entries in a directory
       
   159     RPointerArray<CRsfwDirEnt>* iDirEnts;
       
   160     };
       
   161 
       
   162 #endif // CRSFWDAVTRANSACTION_H
       
   163            
       
   164 // End of File