webservices/wshttpchanneltransportplugin/inc/senhttpsyncrequester.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:           The class for submitting synchronous HTTP requests.
       
    15 *                Create and initialize instance of CSenHttpChannel
       
    16 *                first and pass it as a parameter to this wrapper
       
    17 *                class in a constructor.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 
       
    31 #ifndef WSF_HTTP_SYNC_REQUESTER_H
       
    32 #define WSF_HTTP_SYNC_REQUESTER_H
       
    33 
       
    34 //  INCLUDES
       
    35 #include <badesca.h>
       
    36 
       
    37 #include "senresponseobserver.h"
       
    38 #include "MSenElement.h"
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 class CSenHttpChannel;
       
    42 class CSenLayeredHttpTransportProperties;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 /**
       
    47  * The class for submitting synchronous HTTP requests.
       
    48  * Create and initialize instance of CSenHttpChannel
       
    49  * first and pass it as a parameter to this wrapper
       
    50  * class in a constructor.
       
    51  *
       
    52  */
       
    53 class CSenHttpSyncRequester : public CTimer,
       
    54                               public MSenResponseObserver
       
    55     {
       
    56 public:
       
    57     /**
       
    58      * Two-phased constructor.
       
    59      */
       
    60     static CSenHttpSyncRequester* NewL(CSenHttpChannel* aHttpChannel);
       
    61 
       
    62     /**
       
    63      * Two-phased constructor.
       
    64      */
       
    65     static CSenHttpSyncRequester* NewLC(CSenHttpChannel* aHttpChannel);
       
    66 
       
    67     /**
       
    68      * Two-phased constructor.
       
    69      */
       
    70     static CSenHttpSyncRequester* NewL(CSenHttpChannel* aHttpChannel,
       
    71                                         MSenResponseObserver* aParentObserver);
       
    72 
       
    73     /**
       
    74      * Two-phased constructor.
       
    75      */
       
    76     static CSenHttpSyncRequester* NewLC(CSenHttpChannel* aHttpChannel,
       
    77                                         MSenResponseObserver* aParentObserver);
       
    78 
       
    79     /**
       
    80      * Destructor.
       
    81      */
       
    82     virtual ~CSenHttpSyncRequester();
       
    83 
       
    84     /**
       
    85      * Submit a synchronous HTTP GET request to a given URI.
       
    86      * The method leaves if an error occurs. This method
       
    87      * takes the ownership of the heap buffers aResponseContentType
       
    88      * and aResponseContent.
       
    89      *
       
    90      * @param aRequestUri outgoing request URI.
       
    91      * @param aResponseContentType incoming response content type.
       
    92      * @param aResponseContent incoming response content.
       
    93      */
       
    94     // HTTP GET
       
    95     //TInt SubmitL(const TDesC8& aRequestUri,
       
    96     //                      HBufC8*& aResponseContentType,
       
    97     //                      HBufC8*& aResponseContent,
       
    98     //                      TInt& aErrorCode);
       
    99 
       
   100     /**
       
   101      * Submit a synchronous HTTP POST request to a given URI.
       
   102      * The method leaves if an error occurs. This method
       
   103      * takes the ownership of the heap buffers aResponseContentType
       
   104      * and aResponseContent.
       
   105      *
       
   106      * @param aRequestUri outgoing request URI.
       
   107      * @param aRequestContentType outgoing request content type.
       
   108      * @param aRequestContent outgoing request content.
       
   109      * @param aResponseContentType incoming response content type.
       
   110      * @param aResponseContent incoming response content.
       
   111      */
       
   112     TInt SubmitL(const TDesC8& aRequestUri,
       
   113                  CSenLayeredHttpTransportProperties& aProps,
       
   114                  const TDesC8& aRequestContent,
       
   115                  HBufC8*& aResponseContentType,
       
   116                  HBufC8*& aResponseContent,
       
   117                  TInt& aErrorCode);
       
   118 
       
   119     /*
       
   120     // SOAP envelope version of HTTP POST, IOP
       
   121     TInt SubmitL(const TDesC8& aRequestUri,
       
   122                     const TDesC8* aRequestContentType,
       
   123                     MSenElement& aMessage, // SOAP envelope
       
   124                     HBufC8*& aResponseContentType,
       
   125                     HBufC8*& aResponseContent,
       
   126                     TInt& aErrorCode);
       
   127     */
       
   128 
       
   129         // Functions from base classes
       
   130         
       
   131     /**
       
   132      * Callback method from MSenResponseObserver.
       
   133      */
       
   134     virtual void ResponseReceivedL( TInt aRequestId,
       
   135                                     const TAny* aContentType, 
       
   136                                     HBufC8* apContent,
       
   137                                     CSenHttpTransportProperties* aHttpPrperties = NULL );
       
   138 
       
   139     /**
       
   140      * Callback method from MSenResponseObserver.
       
   141      */
       
   142     virtual void ResponseErrorL(TInt aId, TInt aError, HBufC8* aErrorBody, CSenHttpTransportProperties* aHttpProperties  );
       
   143     virtual void FileProgress(TInt /*aTxnId*/, TBool /*aIncoming*/,
       
   144             TBool /*aIsSoap*/, const TDesC8& /*aSoapOrCid*/, TInt /*aProgress*/)
       
   145         {
       
   146         }
       
   147 
       
   148     virtual void StateChanged(TInt aRequestId, TInt aState); // In order to propagate http status codes
       
   149 	virtual void SetTrafficDetails(TSenDataTrafficDetails& aDetails) ; 
       
   150     virtual MSenProperties& PropertiesL();
       
   151     
       
   152 //from activeObject
       
   153     void DoCancel();
       
   154     void RunL();
       
   155     TInt RunError(TInt /*aError*/);
       
   156 
       
   157 private:
       
   158     CSenHttpSyncRequester(CSenHttpChannel* aHttpChannel,
       
   159                           MSenResponseObserver* aParentObserver);
       
   160     void ConstructL();
       
   161 
       
   162 private:  // Data
       
   163     CSenHttpChannel* iHttpChannel;          // not owned
       
   164     CActiveSchedulerWait iSchedulerWait;
       
   165     TBool isStopped;
       
   166     HBufC8* iContentType;
       
   167     HBufC8* iContent;
       
   168     TInt iStatusCode; // containts KErrNone or some error
       
   169     MSenResponseObserver* iParentObserver;  // not owned
       
   170     };
       
   171 
       
   172 #endif //WSF_HTTP_SYNC_REQUESTER_H
       
   173 
       
   174 // End of File