javacommons/gcfprotocols/http/inc.s60/chttptransactionclient.h
branchRCL_3
changeset 19 04becd199f91
child 80 d6dafc5d983f
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CHTTPTRANSACTIONCLIENT_H
       
    19 #define CHTTPTRANSACTIONCLIENT_H
       
    20 
       
    21 #include <http/rhttpsession.h>
       
    22 #include <http/rhttptransaction.h>
       
    23 #include <http/mhttptransactioncallback.h>
       
    24 #include <http/mhttpdatasupplier.h>
       
    25 #include "monitor.h"
       
    26 
       
    27 class MNativeSecureConnectionInformation;
       
    28 class CX509Certificate;
       
    29 class HttpSessionClient;
       
    30 class CHttpsCertInfo;
       
    31 class MRefHttpClientObserver;
       
    32 class MHTTPAuthenticationCallback;
       
    33 
       
    34 class CHttpTransactionClient : public CBase , public MHTTPTransactionCallback , public MHTTPDataSupplier
       
    35 {
       
    36 public:
       
    37     static CHttpTransactionClient* NewL(HttpSessionClient & aSession,
       
    38                                         MRefHttpClientObserver* aObserver,
       
    39                                         const TDesC* aUri,
       
    40                                         const TDesC* aRequestMethod);
       
    41     /*
       
    42     * After the headers and other details have been set up,
       
    43     * call this function to make the request.
       
    44     * Takes ownership of aPostData
       
    45     */
       
    46     void SubmitL(RPointerArray<HBufC8>* aRawHeaders , TDesC8* aPostData, int aResponseTimeout);
       
    47     /*
       
    48     * Get the response headers back from the transaction
       
    49     */
       
    50     void GetResponseL(RPointerArray<HBufC8>* aRawHeaders);
       
    51 
       
    52     //RHTTPResponse GetResponseL();
       
    53     /*
       
    54     * Call from Jave to attempt to read aLength of Bytes
       
    55     * Returns the total number of bytes read into the buffer,
       
    56     * or -1 if there is no more data because the end of the stream
       
    57     * has been reached.
       
    58     * Returns 0 if native buffer is empty but still more data to read;
       
    59     */
       
    60     TInt ReadBytes(TDes8& aBytesPtr);
       
    61     /*
       
    62     *   CloseTransaction
       
    63     */
       
    64     void CloseTransaction();
       
    65     /*
       
    66     * Get the secutiry information
       
    67     */
       
    68     MNativeSecureConnectionInformation* GetSecurityInfo();
       
    69     /*
       
    70     * Close the transaction and dispose
       
    71     */
       
    72     ~CHttpTransactionClient();
       
    73 
       
    74     /*
       
    75     * Returns the amount of bytes avaible for read in our buffer.
       
    76     */
       
    77     TInt Available();
       
    78 
       
    79     /*
       
    80      * Pre-Condition
       
    81      *The session is opened, but no transactions have been created on it
       
    82      */
       
    83     void SetHTTPAuthenticationCallbackL(MHTTPAuthenticationCallback& aCallBack);
       
    84 
       
    85 private:
       
    86     enum TTransactionState
       
    87     {
       
    88         EFailed                 =-1,
       
    89         ENone                   = 0,
       
    90         ESubmitted              = 1,
       
    91         EGotResponse            = 2,
       
    92         EComplete               = 3,
       
    93         ECancelled              = 4,
       
    94         EGotResponseBodyData    = 5,
       
    95         ERequestNextBodayData   = 6,
       
    96         EClosed                 = 7
       
    97     };
       
    98 private://from MHTTPTransactionCallback
       
    99     // Called when the filter's registration conditions are satisfied for events that   occur on a transaction.
       
   100     void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
   101     //Called when RunL leaves from a transaction event
       
   102     TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
       
   103 private: // from MHTTPDataSupplier
       
   104     //Obtain a data part from the supplier.
       
   105     virtual TBool GetNextDataPart(TPtrC8& aDataPart);
       
   106     // Release the current data part being held
       
   107     virtual void ReleaseData();
       
   108     //Obtain the overall size of the data being supplied
       
   109     virtual TInt OverallDataSize();
       
   110     ///Reset the data supplier.
       
   111     virtual TInt Reset();
       
   112 private://from CJavaEventSource
       
   113     void FinalizeSvr();
       
   114 private:
       
   115     CHttpTransactionClient(HttpSessionClient& aSession, MRefHttpClientObserver* aObserver);
       
   116     void ConstructL(const TDesC* aUri, const TDesC* aRequestMethod);
       
   117     void SetHeaderL(RHTTPHeaders& aHeaders, const TDesC8* aRawField);
       
   118     void NotifyErrorL(TInt aErrorCode);
       
   119     void GetCertInfoL();
       
   120     void OpenTransactionL(const TDesC* aUri, const TDesC* aRequestMethod);
       
   121     const TDesC8& CipherSuiteDescription(const TDesC8& aCode);
       
   122     void StoreOneCookieL(HBufC8*& aRawHeader, RHTTPHeaders aHeaders, TInt aPartIndex, RStringF aFieldName);
       
   123     void AddParam(HBufC8*& aRawHeader, const TDesC8& aName, const TDesC8& aValue);
       
   124 
       
   125 
       
   126 private:
       
   127     HttpSessionClient& iHttpSession;
       
   128     RHTTPTransaction iTransaction;
       
   129     MHTTPDataSupplier* iRespBody;
       
   130     MRefHttpClientObserver* iObserver;
       
   131     CHttpsCertInfo* iCertInfo;
       
   132     java::util::Monitor *iMonitor1;
       
   133     java::util::Monitor *iMonitor2;
       
   134     java::util::Monitor *iMonitor3;
       
   135     HBufC8* iBuf;
       
   136     HBufC8* iDrmBuf;
       
   137     TInt iStatus;
       
   138     TInt iJavaReadOffset;
       
   139     TBool iLastChunk;
       
   140     TBool iJavaWaitingOnCallBack;
       
   141     TBool iJavaWaitingOnReadCallBack;
       
   142     TBool iReleasedData;
       
   143     TBool iTransactionOpen;
       
   144     TBool iRead;
       
   145     TBool iClosing;
       
   146     TBool iDiscardCookie;
       
   147     TInt iMinLength;
       
   148     TBool iDrmDownload;
       
   149     TInt iFlag;
       
   150 };
       
   151 
       
   152 #endif // CHTTPTRANSACTIONCLIENT_H