webservices/wshttpchanneltransportplugin/inc/senhttpchanneltransportplugin.h
changeset 0 62f9d29f7211
child 19 9e96e2676219
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 
       
    26 
       
    27 
       
    28 #ifndef SEN_HTTP_CHANNEL_TRANSPORT_PLUGIN_H
       
    29 #define SEN_HTTP_CHANNEL_TRANSPORT_PLUGIN_H
       
    30 
       
    31 // INCLUDES
       
    32 #include <e32base.h>
       
    33 #include <s32strm.h>
       
    34 #include <s32file.h>    // filestream
       
    35 
       
    36 #include <flogger.h>
       
    37 #include "sendebug.h"
       
    38 #include "sentransport.h"
       
    39 #include "msencoreservicemanager.h"
       
    40 #include "msenremoteserviceconsumer.h"
       
    41 #include "msenservicesession.h"
       
    42 #include "senpointermap.h"
       
    43 #include "senresponseobserver.h"
       
    44 #include "SenHttpTransportProperties.h"
       
    45 #include <SenServiceConnection.h>
       
    46 // CONSTANTS
       
    47 _LIT8(KSenHttpChannelTransportUriScheme,        "http");
       
    48 _LIT8(KSenHttpChannelUserAgentHeaderDefault,    "Serene");
       
    49 _LIT8(KSenHttpChannelAcceptHeaderDefault,       "text/xml");
       
    50 
       
    51 
       
    52 // FORWARD DECLARE
       
    53 class CSenHttpChannel;
       
    54 class CSenHttpSyncRequester;
       
    55 class CSenLayeredHttpTransportProperties;
       
    56 class CSenIdentityProvider;
       
    57 
       
    58 class CSenSoapEnvelope2;
       
    59 
       
    60 // TYPE DEF
       
    61 typedef RSenPointerMap<MSenRemoteServiceConsumer, TInt> RConsumerMap;
       
    62 typedef RSenPointerMap<MSenServiceSession, TInt> RSessionMap;
       
    63 
       
    64 /**********************************************************************
       
    65  Here is the full list of HTTP error codes
       
    66  (taken from: \src\common\generic\application-protocols\http\inc\httperr.h)
       
    67 
       
    68        KErrHttpEncodeDefault                     -7200 
       
    69        KErrHttpEncodeAccept                      -7201 
       
    70        KErrHttpEncodeAcceptCharset               -7202 
       
    71        KErrHttpEncodeQValue                      -7203 
       
    72        KErrHttpEncodeAuthorization               -7204 
       
    73        KErrHttpEncodeBasicAuth                   -7205 
       
    74        KErrHttpEncodeDigestAuth                  -7206 
       
    75        KErrHttpEncodeConnection                  -7207 
       
    76        KErrHttpEncodeContentLength               -7208 
       
    77        KErrHttpEncodeContentType                 -7209 
       
    78        KErrHttpEncodeHost                        -7210 
       
    79        KErrHttpEncodeHostPort                    -7211 
       
    80        KErrHttpEncodeTransferEncoding            -7212 
       
    81        KErrHttpEncodeUserAgent                   -7213 
       
    82        KErrHttpEncodeDate                        -7214 
       
    83        KErrHttpEncodeCookie                      -7215 
       
    84        KErrHttpEncodeCacheControl                -7216 
       
    85        KErrHttpEncodePragma                      -7217 
       
    86        KErrHttpEncodeIfMatch                     -7218 
       
    87        KErrHttpEncodeIfNoneMatch                 -7219 
       
    88        KErrHttpEncodeIfModifiedSince             -7220 
       
    89        KErrHttpEncodeIfUnmodifiedSince           -7221 
       
    90        KErrHttpEncodeCookie2                     -7222 
       
    91        KErrHttpEncodeContentLanguage             -7223 
       
    92        KErrHttpEncodeDoWWWAuthenticate           -7224 
       
    93        KErrHttpEncodeDoAge                       -7225 
       
    94        KErrHttpEncodeDoVary                      -7226 
       
    95        KErrHttpEncodeDoContentLanguage           -7227 
       
    96        KErrHttpEncodeContentEncoding             -7228 
       
    97        KErrHttpEncodeContentLocation             -7229 
       
    98        KErrHttpEncodeContentMD5                  -7230 
       
    99        KErrHttpEncodeAcceptLanguage              -7231 
       
   100        KErrHttpEncodeAcceptEncoding              -7232 
       
   101        KErrHttpEncodeTE                          -7233 
       
   102                                                        
       
   103        KErrHttpDecodeMalformedDate               -7260 
       
   104        KErrHttpDecodeMalformedYear               -7261 
       
   105        KErrHttpDecodeMalformedMonth              -7262 
       
   106        KErrHttpDecodeMalformedDay                -7263 
       
   107        KErrHttpDecodeMalformedWkDay              -7264 
       
   108        KErrHttpDecodeMalformedWeekDay            -7265 
       
   109        KErrHttpDecodeMalformedInteger            -7266 
       
   110        KErrHttpDecodeMalformedQuotedStr          -7267 
       
   111                                                        
       
   112        KErrHttpDecodeAccept                      -7270 
       
   113        KErrHttpDecodeConnection                  -7271 
       
   114        KErrHttpDecodeContentLength               -7272 
       
   115        KErrHttpDecodeContentType                 -7273 
       
   116        KErrHttpDecodeTransferEncoding            -7274 
       
   117        KErrHttpDecodeWWWAuthenticate             -7275 
       
   118        KErrHttpDecodeUnknownAuthScheme           -7276 
       
   119        KErrHttpDecodeBasicAuth                   -7277 
       
   120        KErrHttpDecodeDigestAuth                  -7278 
       
   121        KErrHttpDecodeCookie                      -7279 
       
   122        KErrHttpDecodeAuthorization               -7280 
       
   123        KErrHttpDecodeAcceptCharset               -7281 
       
   124        KErrHttpDecodeAcceptLanguage              -7282 
       
   125        KErrHttpDecodeAcceptEncoding              -7283 
       
   126        KErrHttpDecodeTE                          -7284 
       
   127        KErrHttpDecodeExpect                      -7285 
       
   128                                                        
       
   129        KErrHttpRedirectExceededLimit             -7300 
       
   130        KErrHttpRedirectUseProxy                  -7301 
       
   131        KErrHttpRedirectNoLocationField           -7302 
       
   132        KErrHttpUnknownParseState                 -7303 
       
   133                                                        
       
   134        KErrHttpRequestHasBody                    -7330 
       
   135        KErrHttpRequestBodyMissing                -7331 
       
   136        KErrHttpTraceReqWithoutMaxForwardHeader   -7332 
       
   137        KErrHttpPostReqBodyWithoutSizeOnHTTP10    -7333 
       
   138        KErrHttpInvalidHeaderInRequest            -7334 
       
   139                                                        
       
   140        KErrHttpEntityHeaderMissingContentType    -7360 
       
   141        KErrHttpGeneralHeaderMissingHost          -7361 
       
   142                                                        
       
   143        KErrHttpCantResetRequestBody              -7370 
       
   144        KErrHttpProtTransactionNotInitialised     -7371 
       
   145        KErrHttpCannotEstablishTunnel             -7372 
       
   146        KErrHttpInvalidUri                        -7373 
       
   147        KErrHttpNonPipeliningError                -7374 
       
   148        KErrHttpPipeliningError                   -7375 
       
   149 
       
   150  ***********************************************************************/
       
   151 
       
   152 // CLASS DECLARATION
       
   153 class CSenHttpChannelTransportPlugin : public CSenTransport,
       
   154                                        public MSenResponseObserver
       
   155     {
       
   156     public: // Constructors and destructor
       
   157     
       
   158         static CSenHttpChannelTransportPlugin* NewL(CSenTransportContext* apCtx);
       
   159         static CSenHttpChannelTransportPlugin* NewLC(CSenTransportContext* apCtx);
       
   160 
       
   161         //static CSenHttpChannelTransportPlugin* NewL(MSenCoreServiceManager& aServiceManager);
       
   162         //static CSenHttpChannelTransportPlugin* NewLC(MSenCoreServiceManager& aServiceManager);
       
   163 
       
   164         /*        
       
   165         // @depracated: remove when Transport Properties is used as initializer:
       
   166         static CSenHttpChannelTransportPlugin* NewL(MSenCoreServiceManager& aManager,
       
   167                                                     TInt aProxyPort,
       
   168                                                     TPtrC8 aProxyHost);
       
   169 
       
   170         // @depracated: remove when Transport Properties is used as initializer:
       
   171         static CSenHttpChannelTransportPlugin* NewLC(MSenCoreServiceManager& aManager,
       
   172                                                      TInt aProxyPort,
       
   173                                                      TPtrC8 aProxyHost);
       
   174 
       
   175         // @depracated: remove when Transport Properties is used as initializer:
       
   176         static CSenHttpChannelTransportPlugin* NewL(MSenCoreServiceManager& aManager,
       
   177                                                     TUint32 aIapId);
       
   178 
       
   179         // @depracated: remove when Transport Properties is used as initializer:
       
   180         static CSenHttpChannelTransportPlugin* NewLC(MSenCoreServiceManager& aManager,
       
   181                                                      TUint32 aIapId);
       
   182     
       
   183         // @depracated: remove when Transport Properties is used as initializer:
       
   184         static CSenHttpChannelTransportPlugin* NewL(MSenCoreServiceManager& aManager, 
       
   185                                                     TInt aProxyPort, 
       
   186                                                     TPtrC8 aProxyHost,
       
   187                                                     TUint32 aIapId);
       
   188 
       
   189         // @depracated: remove when Transport Properties is used as initializer:
       
   190         static CSenHttpChannelTransportPlugin* NewLC(MSenCoreServiceManager& aManager, 
       
   191                                                      TInt aProxyPort, 
       
   192                                                      TPtrC8 aProxyHost,
       
   193                                                      TUint32 aIapId);
       
   194         */
       
   195 
       
   196         virtual ~CSenHttpChannelTransportPlugin();
       
   197 
       
   198         // from MSenResponseObserver
       
   199 
       
   200         /**
       
   201         * Receive response to a request submitted. This method
       
   202         * takes the ownership of the heap buffer aContent.
       
   203         *
       
   204         * @param aRequestId submit id which identifies the request.
       
   205         * @param aContentType incoming response content type.
       
   206         * @param aContent incoming response content, or NULL.
       
   207         * @param aHttpProperties - properies of response(e.g.such as file names where BLOBs are saved) or NULL
       
   208         */
       
   209         virtual void ResponseReceivedL(TInt aRequestId,
       
   210                                        const TAny* aContentType, 
       
   211                                        HBufC8* aContent,
       
   212                                        CSenHttpTransportProperties* aHttpProperties = NULL);
       
   213 
       
   214         /**
       
   215         * Error occured while receiving response. Error code
       
   216         * is either system error code or own error code. Own
       
   217         * error codes start from -20000
       
   218         *
       
   219         * @param aRequestId submit id which identifies the request.
       
   220         * @param aErrorCode  error code of the response.
       
   221         * @param aErrorBody is the received error response. Might
       
   222         *       be zero-lenght, if nothing was received.
       
   223         */
       
   224         virtual void ResponseErrorL(TInt aRequestId, TInt aError, HBufC8* aErrorBody,
       
   225                                     CSenHttpTransportProperties* aHttpProperties = NULL);
       
   226 
       
   227         // from MSenTransport
       
   228 
       
   229         virtual TInt SubmitL(const TDesC8& aEndpoint,
       
   230                              const TDesC8& aMessage,
       
   231                              const TDesC8& aTransportProperties,
       
   232                              HBufC8*& aResponse,
       
   233                              MSenRemoteServiceConsumer& aConsumer);
       
   234 
       
   235         virtual TInt SendL(const TDesC8& aEndpoint,
       
   236                            const TDesC8& aMessage,
       
   237                            const TDesC8& aTransportProperties,
       
   238                            MSenServiceSession& aReplyTo,
       
   239                            MSenRemoteServiceConsumer& aConsumer, // "adressee", could be CSenIdentifier
       
   240                            TInt& aTxnId);
       
   241 
       
   242         virtual TInt SetPropertiesL(const TDesC8& aProperties, 
       
   243                                     MSenLayeredProperties::TSenPropertiesLayer aTargetLayer,
       
   244                                     MSenRemoteServiceConsumer* aConsumer);
       
   245         virtual TInt PropertiesL(HBufC8*& aProperties);
       
   246         virtual TInt CompleteTransaction(const TInt aTxnId, const TInt aStatus);
       
   247         virtual TInt CancelTransaction(const TInt aTxnId);
       
   248         virtual TPtrC8 UriSchemeL();
       
   249         
       
   250         virtual MSenProperties& PropertiesL();
       
   251         
       
   252         virtual void StateChanged(TInt aId, TInt aState); // in order to propagate http status codes
       
   253         virtual void FileProgress(TInt aTxnId, TBool aIncoming, TBool aIsSoap,
       
   254             const TDesC8& aSoapOrCid, TInt aProgress);
       
   255 		virtual void SetTrafficDetails(TSenDataTrafficDetails& aDetails);
       
   256         void DataTrafficDetails(TSenDataTrafficDetails& aDetails); 	
       
   257     protected:
       
   258     
       
   259         /**
       
   260         * C++ default constructor.
       
   261         * @param apCtx - ownership is taken to this instance(!)
       
   262         */
       
   263 
       
   264         CSenHttpChannelTransportPlugin(CSenTransportContext* apCtx,
       
   265                                        MSenCoreServiceManager& aCore);
       
   266         //CSenHttpChannelTransportPlugin(MSenCoreServiceManager& aServiceManager);
       
   267 
       
   268     private:
       
   269         /**
       
   270         * 2nd phase constructor
       
   271         */
       
   272         void ConstructL();
       
   273 
       
   274         // @depracated: remove when Transport Properties is used as initializer:
       
   275         //void ConstructL(TInt aProxyPort, TPtrC8 aProxyHost);
       
   276         // @depracated: remove when Transport Properties is used as initializer:
       
   277         //void ConstructL(TUint32 aIapId);
       
   278         // @depracated: remove when Transport Properties is used as initializer:
       
   279         //void ConstructL(TInt aProxyPort, TPtrC8 aProxyHost, TUint32 aIapId);
       
   280 
       
   281         /**
       
   282         * Helper, which resets HTTP transport properties
       
   283         */
       
   284         TInt ApplyPropertiesL();
       
   285 
       
   286         TInt ResetHttpChannelByIapIdL(TUint32 aIapId);
       
   287 
       
   288         CSenLayeredHttpTransportProperties& LayeredPropertiesL();
       
   289         
       
   290 
       
   291         /**
       
   292         * Logging 
       
   293         */
       
   294         //RFileLogger* Log() const;
       
   295         
       
   296     private: // data
       
   297         MSenCoreServiceManager& iServiceManager; // not owned
       
   298         CSenHttpSyncRequester* iRequester;
       
   299         CSenHttpChannel *iHttpChannel;
       
   300         CSenLayeredHttpTransportProperties* iProperties;
       
   301         RConsumerMap iConsumerMap; // values owned (TxnIds), keys not (consumers)
       
   302         RSessionMap iSessionMap;   // values NOT owned (TxnIds), neither keys (sessions)
       
   303         //RFileLogger iLogger;
       
   304         TInt iStatusCode; // containts latest error or zero
       
   305 		TSenDataTrafficDetails iDetails;
       
   306     };
       
   307 
       
   308 #endif // SEN_HTTP_CHANNEL_TRANSPORT_PLUGIN_H
       
   309 
       
   310 // End of File