xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpContSupplier.cpp
branchRCL_3
changeset 17 2669f8761a99
parent 16 2580314736af
child 18 fbd2e7cec7ef
equal deleted inserted replaced
16:2580314736af 17:2669f8761a99
     1 /*
       
     2 * Copyright (c) 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:   CXcapHttpContSupplier
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "XcapHttpTransport.h"
       
    23 #include "XcapHttpContSupplier.h"
       
    24 
       
    25 // ================= MEMBER FUNCTIONS =======================
       
    26 //
       
    27 
       
    28 // ----------------------------------------------------------
       
    29 // CXcapHttpContSupplier::CXcapHttpContSupplier
       
    30 // 
       
    31 // ----------------------------------------------------------
       
    32 //
       
    33 CXcapHttpContSupplier::CXcapHttpContSupplier( RHTTPSession& aHttpSession,
       
    34                                               CXcapHttpAuthManager& aAuthManager,
       
    35                                               CXcapHttpTransport& aTransportMain ) :
       
    36                                               CXcapHttpRequest( aHttpSession, aAuthManager, aTransportMain )
       
    37                                         
       
    38     {
       
    39     }
       
    40 
       
    41 // ----------------------------------------------------------
       
    42 // CXcapHttpContSupplier::~CXcapHttpContSupplier
       
    43 // 
       
    44 // ----------------------------------------------------------
       
    45 //
       
    46 CXcapHttpContSupplier::~CXcapHttpContSupplier()
       
    47     {
       
    48     #ifdef _DEBUG
       
    49         iTransportMain.WriteToLog( _L8( "CXcapHttpContSupplier::~CXcapHttpContSupplier()" ) );    
       
    50     #endif
       
    51     delete iRequestBody;
       
    52     }
       
    53 
       
    54 // ----------------------------------------------------------
       
    55 // CXcapHttpContSupplier::SetRequestBodyL
       
    56 // 
       
    57 // ----------------------------------------------------------
       
    58 //
       
    59 EXPORT_C void CXcapHttpContSupplier::SetRequestBodyL( const TDesC8& aRequestBody )
       
    60     {
       
    61     #ifdef _DEBUG
       
    62         iTransportMain.WriteToLog( _L8( "CXcapHttpContSupplier::SetRequestBodyL" ) );    
       
    63     #endif
       
    64     delete iRequestBody;
       
    65     iRequestBody = NULL;
       
    66     iRequestBody = HBufC8::NewL( aRequestBody.Length() );
       
    67     iRequestBody->Des().Copy( aRequestBody );
       
    68     }
       
    69 
       
    70 // ----------------------------------------------------------
       
    71 // CXcapHttpContSupplier::RequestBody
       
    72 // 
       
    73 // ----------------------------------------------------------
       
    74 //
       
    75 EXPORT_C TPtrC8 CXcapHttpContSupplier::RequestBody() const
       
    76     {
       
    77     #ifdef _DEBUG
       
    78         iTransportMain.WriteToLog( _L8( "CXcapHttpContSupplier::RequestBody" ) );    
       
    79     #endif
       
    80     return iRequestBody != NULL ? iRequestBody->Des() : TPtrC8();
       
    81     }
       
    82     
       
    83 // ----------------------------------------------------------
       
    84 // CXcapHttpContSupplier::GetNextDataPart
       
    85 // 
       
    86 // ----------------------------------------------------------
       
    87 //
       
    88 TBool CXcapHttpContSupplier::GetNextDataPart( TPtrC8& aDataPart )
       
    89     {
       
    90     aDataPart.Set( iRequestBody->Des() );
       
    91     return ETrue;
       
    92     }
       
    93 
       
    94 // ----------------------------------------------------------
       
    95 // CXcapHttpContSupplier::ReleaseData
       
    96 // 
       
    97 // ----------------------------------------------------------
       
    98 //
       
    99 void CXcapHttpContSupplier::ReleaseData()
       
   100     {
       
   101     #ifdef _DEBUG
       
   102         iTransportMain.WriteToLog( _L8( "CXcapHttpContSupplier::ReleaseData()" ) );    
       
   103     #endif
       
   104     //Not just yet, lets see if the server accepts the data.
       
   105     //If it does, the data needs to be cached and this is
       
   106     //probably  - and hopefully - the only copy of the raw 
       
   107     //data still available at that point in time
       
   108     //delete iRequestBody;
       
   109     //iRequestBody = NULL;
       
   110     }
       
   111 
       
   112 // ----------------------------------------------------------
       
   113 // CXcapHttpContSupplier::Reset
       
   114 // 
       
   115 // ----------------------------------------------------------
       
   116 //
       
   117 TInt CXcapHttpContSupplier::Reset()
       
   118 	{
       
   119 	//This method is called when client Cancel()s a request.
       
   120 	//There's nothing to reset in our case, because all needed
       
   121 	//resources are destructed in the destructor.
       
   122 	//NOTE: Never EVER set this method to return anything but
       
   123 	//KErrNone, since values < 0 will result in practically
       
   124 	//untraceable errors thanks to Symbian's lack of proper
       
   125 	//documentation on the issue.
       
   126 	return KErrNone;
       
   127 	}
       
   128 
       
   129 // ----------------------------------------------------------
       
   130 // CXcapHttpContSupplier::GetNextDataPart
       
   131 // 
       
   132 // ----------------------------------------------------------
       
   133 //
       
   134 TInt CXcapHttpContSupplier::OverallDataSize()
       
   135 	{
       
   136     return iRequestBody != NULL ? iRequestBody->Length() : 0;
       
   137 	}
       
   138 
       
   139