webservices/wshttpchanneltransportplugin/inc/senmultiparttxnstate.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef WSF_MultiPart_TXN_STATE_H
       
    26 #define WSF_MultiPart_TXN_STATE_H
       
    27 
       
    28 //  INCLUDES
       
    29 #include "sentxnstate.h"
       
    30 #include "senmultipartutils.h"
       
    31 
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 
       
    36 	
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42  * Class for working with MultiPart messages - creates MultiPart request and parse MultiPart response
       
    43  * Implements the MHTTPDataSupplier interface.
       
    44  *
       
    45  */
       
    46 class CSenMultiPartTxnState : public CSenTxnState
       
    47     {
       
    48 public:  // Constructors and destructor
       
    49 
       
    50     
       
    51     /**
       
    52      * Virtual destructor.
       
    53      *
       
    54      */
       
    55     virtual ~CSenMultiPartTxnState();
       
    56 
       
    57     // New functions
       
    58 
       
    59     /**
       
    60      * Parses Response from server (MultiPart message) 
       
    61      * @param aDataPart Part of data come from server side
       
    62      */ 
       
    63     void ParseMultiPartResponseL(TDesC8& aDataPart);
       
    64 
       
    65     /**
       
    66      * Added HttpTransportProperties about Cids of Blobs and File names, 
       
    67      * where Blobs are kept and passes transport properties and XopEnvelope 
       
    68      * to an observer
       
    69      * @param aMultiPartContentType ContentType of MultiPart Response
       
    70      */
       
    71     void ResponseReceivedL(const SenMultiPartUtils::TMultiPartContentType& aMultiPartContentType);
       
    72 
       
    73     // Functions from base classes
       
    74 
       
    75     /**
       
    76      * From MHTTPDataSupplier::GetNextDataPart.
       
    77      * Obtain a data part from the supplier.  The data is guaranteed
       
    78      * to survive until a call is made to ReleaseData().
       
    79      * @param aDataPart The data part that sould be sent to server side.
       
    80      * @return ETrue if this is the last part, EFalse otherwise.
       
    81      */
       
    82     virtual TBool GetNextDataPart(TPtrC8& aDataPart);
       
    83 
       
    84     /**
       
    85      * From MHTTPDataSupplier::ReleaseData.
       
    86      * Release the current data part being held at the data
       
    87      * supplier.  This call indicates to the supplier that the part
       
    88      * is no longer needed, and another one can be supplied, if
       
    89      * appropriate.
       
    90      */
       
    91     virtual void ReleaseData();
       
    92 
       
    93     /**
       
    94      * From MHTTPDataSupplier::OverallDataSize.
       
    95      * Obtain the overall size of the data being supplied, if known
       
    96      * to the supplier.  Where a body of data is supplied in several
       
    97      * parts this size will be the sum of all the part sizes. If
       
    98      * the size is not known, KErrNotFound is returned; in this case
       
    99      * the client must use the return code of GetNextDataPart to find
       
   100      * out when the data is complete.
       
   101      *
       
   102      * @return A size in bytes, or KErrNotFound if the size is not known.
       
   103      */
       
   104     virtual TInt OverallDataSize();
       
   105 
       
   106     /**
       
   107      * From MHTTPDataSupplier::Reset.
       
   108      * Reset the data supplier.  This indicates to the data supplier
       
   109      * that it should return to the first part of the data.
       
   110      * This could be used in a situation where the data consumer has
       
   111      * encountered an error and needs the data to be supplied afresh.
       
   112      * Even if the last part has been supplied (i.e. GetNextDataPart
       
   113      * has returned ETrue), the data supplier should reset to the
       
   114      * first part. If the supplier cannot reset it should return an
       
   115      * error code; otherwise it should return KErrNone, where the
       
   116      * reset will be assumed to have succeeded.
       
   117      *
       
   118      * @return KErrNone if successful, otherwise another error code.
       
   119      */
       
   120     virtual TInt Reset();
       
   121     
       
   122     /**
       
   123      * From CSenTxnState
       
   124      * Creates and sets ContentType in MultiPart header
       
   125      * @param aSession
       
   126      * @param aHeaders
       
   127      */
       
   128     virtual void SetContentTypeHeaderL(const RHTTPSession aSession, RHTTPHeaders aHeaders) = 0;
       
   129     
       
   130     
       
   131 protected:
       
   132 
       
   133     /**
       
   134      * C++ default constructor.
       
   135      *
       
   136      */
       
   137     CSenMultiPartTxnState(MSenResponseObserver& aObserver);
       
   138 
       
   139                
       
   140     // New functions
       
   141 
       
   142     /**
       
   143      * Creates Request for MultiPart message in MultiPart format 
       
   144      * should be used to send MultiPart message through HTTP Channel
       
   145      * @param aDataPart The data part that sould be sent to server side.
       
   146      * @return ETrue if this is the last part, EFalse otherwise.
       
   147      */
       
   148     TBool GetNextDataPartL(TPtrC8& aDataPart);
       
   149                                         
       
   150     /**
       
   151      * Calculates number of parts in BLOB (every part = 10KB) 
       
   152      * and how many bytes there are in the last part
       
   153      * @param aIndex Which Blob from an array should be calculated.
       
   154      */
       
   155     void SizeBinaryData(TUint aIndex);
       
   156     
       
   157     /**
       
   158      * Creates header for Blob in Request
       
   159      */
       
   160     void BlobHeaderL();
       
   161     
       
   162     /**
       
   163      * for case if Blob is kept in a file 
       
   164      * This function passes Blob from a file part by part (every part = 10KB)
       
   165      * in Request
       
   166      * @param aIndex Which Blob from an array should be passed.
       
   167      */
       
   168     void FileContainerL(TUint aIndex);
       
   169     
       
   170     /**
       
   171      * Creates the last part (MimeBoundaryEnd) in Request
       
   172      */
       
   173     void XopEndL();
       
   174     
       
   175     /**
       
   176      * Parses Response from server (MultiPart message) and extracts MimeBoundary part
       
   177      * and MimeBoundaryEnd part
       
   178      * @param aDataPartPtr DataPart come from server that to be parsed and after parsing 
       
   179      *                     changed aDataPartPtr will be used for future parsing 
       
   180      *                     (ParseMultiPartResponse() function)  
       
   181      * @param aOffset Global offset using since beginning of calling ParseMultiPartResponse(). 
       
   182      * @param aOffset1 Global offset1 (searches the end of MultiPart message)
       
   183                        using since beginning of calling ParseMultiPartResponse(). 
       
   184      */
       
   185     void MimeBoundaryInL(TPtrC8& aDataPartPtr, TInt& aOffset, TInt& aOffset1);
       
   186     
       
   187     /**
       
   188      * Parses Response from server (MultiPart message) and extracts XopEnvelope part
       
   189      * @param aDataPartPtr DataPart come from server that to be parsed and after parsing 
       
   190      *                     changed aDataPartPtr will be used for future parsing 
       
   191      *                     (ParseMultiPartResponse() function)  
       
   192      * @param aOffset Global offset using since beginning of calling ParseMultiPartResponse(). 
       
   193      * @param aOffset1 Global offset1 (searches the end of MultiPart message)
       
   194                        using since beginning of calling ParseMultiPartResponse(). 
       
   195      */
       
   196     void XopEnvelopeResponseL(TPtrC8& aDataPartPtr, TInt& aOffset, TInt& aOffset1);    
       
   197 
       
   198     /**
       
   199      * Parses Response from server (MultiPart message) and extracts header of Blob part
       
   200      * @param aDataPartPtr DataPart come from server that to be parsed and after parsing 
       
   201      *                     changed aDataPartPtr will be used for future parsing 
       
   202      *                     (ParseMultiPartResponse() function)  
       
   203      * @param aOffset Global offset using since beginning of calling ParseMultiPartResponse(). 
       
   204      * @param aOffset1 Global offset1 (searches the end of MultiPart message)
       
   205                        using since beginning of calling ParseMultiPartResponse(). 
       
   206      */
       
   207     void BlobHeaderResponseL(TPtrC8& aDataPartPtr, TInt& aOffset, TInt& aOffset1); 
       
   208     
       
   209     /**
       
   210      * Parses Response from server (MultiPart message) and extracts Blob part
       
   211      * and puts it in the file
       
   212      * @param aDataPartPtr DataPart come from server that to be parsed and after parsing 
       
   213      *                     changed aDataPartPtr will be used for future parsing 
       
   214      *                     (ParseMultiPartResponse() function)  
       
   215      * @param aOffset Global offset using since beginning of calling ParseMultiPartResponse(). 
       
   216      * @param aOffset1 Global offset1 (searches the end of MultiPart message)
       
   217                        using since beginning of calling ParseMultiPartResponse(). 
       
   218      */
       
   219     void BlobResponseL(TPtrC8& aDataPartPtr, TInt& aOffset, TInt& aOffset1);
       
   220     
       
   221         // New functions
       
   222 
       
   223                                         
       
   224  
       
   225     /**
       
   226      * Creates header for SoapEnvelope in Request
       
   227      */
       
   228     virtual void MessageHeaderL();
       
   229     
       
   230     /**
       
   231      * Creates SoapEnvelope in Request
       
   232      */
       
   233     virtual void MessageL();
       
   234     
       
   235 
       
   236 protected: // Data
       
   237 
       
   238     
       
   239 	// stores an array consisting Blobs (Request)
       
   240    	RArray<TXmlEngDataContainer> iBinaryDataList; // owned
       
   241    	
       
   242    	// stores XopEnvelope come from server side (Response)
       
   243    	RBuf8 iXopEnvelopeResponse;         // owned
       
   244    	
       
   245    	// stores SoapAction taken from HttpTransportProperties
       
   246     RBuf8 iSoapAction;                  // owned   
       
   247 	
       
   248 	// stores content-ID for root header (Request)
       
   249 	RBuf8 iRootCid;                     // owned
       
   250 	
       
   251 	// stores MimeBoundary of MultiPart (Request)
       
   252 	RBuf8 iMimeBoundaryOut;             // owned
       
   253 	
       
   254 	// stores MimeBoundary of MultiPart (Response)
       
   255 	RBuf8 iMimeBoundaryIn;              // owned
       
   256 	
       
   257 	// stores MimeBoundaryEnd of MultiPart (Response)
       
   258 	RBuf8 iMimeBoundaryEndIn;           // owned
       
   259 	
       
   260 	// stores header of Blob (Response)
       
   261 	RBuf8 iBlobHeader;                  // owned  
       
   262     
       
   263     // stores number of a part that sould be sent (Request) 
       
   264     TUint iPartDataOut;
       
   265     
       
   266     // stores is it the last part or not (Request)
       
   267     TBool iLastPartOut;
       
   268     
       
   269     // stores number of a part that comes from server (Response)
       
   270     TUint iPartDataIn;
       
   271     
       
   272     // stores is it the last part or not (Response)
       
   273     TBool iLastPartIn;
       
   274     
       
   275     // stores how many parts there are in XOP (Request)
       
   276    	TUint iCountDataParts;
       
   277    	
       
   278    	// stores the data of current part that should be sent (Request) 
       
   279    	RBuf8 iCurrentPart;                 // owned
       
   280    	
       
   281    	// stores is it still CurrentPart or now goes a new one - 
       
   282    	//for big parts that HttpChannel can't get at once  (Request)
       
   283    	TBool iCurPart;
       
   284    	
       
   285    	// stores is it end of Blob (Request)
       
   286    	TBool iBinaryDataEnd;
       
   287    	
       
   288    	// stores status that size of Blob was calculated/wasn't calculated (Request)
       
   289  	TBool iChecked;
       
   290  	
       
   291  	// stores which part of Blob goes to the server (Request)
       
   292  	TUint iBinaryDataPart;
       
   293  	
       
   294  	// stores number of Blob parts (calculated in SizeBinaryData() function)
       
   295  	TUint iBinaryDataParts;
       
   296  	
       
   297  	// stores hom many bytes there are in the last Blob part (calculated in SizeBinaryData())
       
   298  	TUint iBinaryDataRest;
       
   299  	
       
   300  	// stores was already created File for incoming Blob or not (Response)
       
   301  	TBool iFirst;
       
   302  	
       
   303  	// stores array of Cids of incoming Blobs (Response)
       
   304  	RArray<RBuf8> iCids;                // owned
       
   305  	
       
   306  	// stores array of file names of incoming Blobs (Response)
       
   307  	RArray<RBuf8> iFileNames;           // owned
       
   308  	
       
   309  	MSenMessage* iMessage;
       
   310     };
       
   311 
       
   312 #endif // WSF_MultiPart_TXN_STATE_H
       
   313 
       
   314 // End of File