browserutilities/downloadmgr/DownloadMgrClntSrv/src/DownloadMgrTransObserver.cpp
changeset 0 dd21522fd290
child 36 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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 the License "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 *     This file contains the declaration of transaction observer of Download Mgr Server.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "DownloadMgrTransObserver.h"
       
    22 #include "DownloadMgrClient.h"
       
    23 
       
    24 // CONSTANTS
       
    25 
       
    26 
       
    27 // GLOBAL FUNCTIONS
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =======================
       
    30 
       
    31 // ---------------------------------------------------------
       
    32 // CTransactionObserver::NewL
       
    33 // ---------------------------------------------------------
       
    34 //
       
    35 CTransactionObserver* CTransactionObserver::NewL( RHttpDownload* aDownload )
       
    36     {
       
    37     CTransactionObserver* self = new( ELeave ) CTransactionObserver( aDownload );
       
    38     
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop();
       
    42 
       
    43     return self;
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------
       
    47 // CTransactionObserver::CTransactionObserver
       
    48 // ---------------------------------------------------------
       
    49 //
       
    50 CTransactionObserver::CTransactionObserver( RHttpDownload* aDownload )
       
    51     {
       
    52     iDownload = aDownload;
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------
       
    56 // CTransactionObserver::ConstructL
       
    57 // ---------------------------------------------------------
       
    58 //
       
    59 void CTransactionObserver::ConstructL()
       
    60     {
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------
       
    64 // CTransactionObserver::CTransactionObserver
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 CTransactionObserver::~CTransactionObserver()
       
    68     {
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CTransactionObserver::MHFRunL
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 void CTransactionObserver::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
       
    76     {
       
    77     switch( aEvent.iStatus )
       
    78         {
       
    79         case THTTPEvent::EGotResponseBodyData:
       
    80             {
       
    81             MHTTPDataSupplier* respBody = aTransaction.Response().Body();
       
    82             TPtrC8 buf;
       
    83 
       
    84             respBody->GetNextDataPart( buf );
       
    85 
       
    86             iDownload->SetStringAttribute( EDlAttrContinueBody, buf );
       
    87 
       
    88             respBody->ReleaseData();
       
    89             }
       
    90             break;
       
    91 
       
    92         case THTTPEvent::ESucceeded:
       
    93             {
       
    94             iDownload->SetIntAttribute( EDlAttrSucceeded, 0 );
       
    95             }
       
    96             break;
       
    97 
       
    98         case THTTPEvent::EFailed:
       
    99         case THTTPEvent::EMoreDataReceivedThanExpected:
       
   100         case THTTPEvent::EUnrecoverableError:
       
   101         case THTTPEvent::ETooMuchRequestData:
       
   102             {
       
   103             iDownload->SetIntAttribute( EDlAttrFailed, aEvent.iStatus );
       
   104             }
       
   105             break;
       
   106 
       
   107         case THTTPEvent::ERedirectedPermanently:
       
   108             {
       
   109             iDownload->SetStringAttribute( EDlAttrRedirectedPermanently, 
       
   110                                            aTransaction.Request().URI().UriDes() );
       
   111             }
       
   112             break;
       
   113 
       
   114         case THTTPEvent::ERedirectedTemporarily:
       
   115             {
       
   116             iDownload->SetStringAttribute( EDlAttrRedirectedTemporary, 
       
   117                                            aTransaction.Request().URI().UriDes() );
       
   118             }
       
   119             break;
       
   120             
       
   121         default:
       
   122             {
       
   123             if ( aEvent.iStatus == KErrHttpPartialResponseReceived )
       
   124                 {
       
   125                 //Partial response has been received and connection has been disconnected. This error will be 
       
   126                 //propagated to the client only, if the HTTP:ENotifyOnDisconnect property is set with a value
       
   127                 //HTTP::EEnableDisconnectNotification
       
   128                 
       
   129                 //This error code was cancelling the pausable download. This error shud be ignored to keep the
       
   130                 //paused download.
       
   131                 //TSW Err ID : SXUU-77SRWL
       
   132                 }
       
   133                 
       
   134             else if( aEvent.iStatus < 0 )
       
   135                 // error occured -> leave will be handled in OnError()
       
   136                 {
       
   137                 iDownload->SetIntAttribute( EDlAttrFailed, aEvent.iStatus );
       
   138                 }
       
   139             }
       
   140             break;
       
   141         }
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------
       
   145 // CTransactionObserver::MHFRunError
       
   146 // ---------------------------------------------------------
       
   147 //
       
   148 TInt CTransactionObserver::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
       
   149     {
       
   150     iDownload->SetIntAttribute( EDlAttrFailed, aError );
       
   151     iDownload->DeleteTransaction();
       
   152     
       
   153     return KErrNone;
       
   154     }
       
   155