upnpmediaserver/contentdirectoryservice/src/upnptransferbase.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /** @file
       
     2 * Copyright (c) 2007 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:  class for sending HTTP request using Symbian HTTP client 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "upnptransferbase.h"
       
    21 #include "upnpcontentdirectory.h"
       
    22 #include "httptransferbase.h"
       
    23 #include "upnptransferobserver.h"
       
    24 
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CUpnpTransferBase::CUpnpTransferBase
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CUpnpTransferBase::CUpnpTransferBase( MUpnpTransferObserver* aObserver )
       
    35     {
       
    36     iObserver = aObserver;
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CUpnpTransferBase::~CUpnpTransferBase
       
    41 // Destructor
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CUpnpTransferBase::~CUpnpTransferBase()
       
    45     {
       
    46     if ( iHttpTransferBase ) 
       
    47         {
       
    48         delete iHttpTransferBase;
       
    49         }
       
    50     }
       
    51 
       
    52 TInt CUpnpTransferBase::MapStatus( TInt aStatus )
       
    53     {   
       
    54     switch ( aStatus ) 
       
    55         {
       
    56         case KErrNone:
       
    57             return EHttpOk;
       
    58         }
       
    59     // default
       
    60     return aStatus;        
       
    61     }
       
    62     
       
    63 void CUpnpTransferBase::CreateAndQueueHttpFileL( const TDesC8& aUri,
       
    64                                                  const TDesC& aTargetPath, 
       
    65                                                  TInt aKey )
       
    66     {
       
    67     iHttpTransferBase->InsertFileIntoWaitQueueL( ( TAny* ) aKey, 
       
    68                                                  aTargetPath,
       
    69                                                  aUri );
       
    70     }
       
    71     
       
    72 void CUpnpTransferBase::SetHeaderL( TInt aKey,
       
    73                                     const TDesC8& aFieldName, 
       
    74                                     const TDesC8& aFieldValue )
       
    75     {
       
    76     iHttpTransferBase->SetHeaderL( ( TAny * )aKey, aFieldName, aFieldValue );
       
    77     }
       
    78 
       
    79 
       
    80 void CUpnpTransferBase::TransferCompleted( TAny* aKey, TInt aStatus )
       
    81     {   
       
    82     TInt contentDirStatus = MapStatus( aStatus );        
       
    83     TRAP_IGNORE( iObserver->TransferCompletedL( (TInt) aKey, contentDirStatus ) );
       
    84     }
       
    85 void CUpnpTransferBase::TrackProgess(TInt aKey, TBool aSwitchOn)
       
    86     {
       
    87     iHttpTransferBase->TrackProgress( (TAny*)aKey, aSwitchOn);
       
    88     }
       
    89     
       
    90 void CUpnpTransferBase::TransferProgress( TAny* aKey, 
       
    91                                            TInt aBytes,
       
    92                                            TInt aTotalBytes )
       
    93     {   
       
    94     iObserver->TransferProgress( (TInt)aKey, aBytes, aTotalBytes);    
       
    95     }    
       
    96 
       
    97 void CUpnpTransferBase::ReadyForTransferL(TAny* aKey)
       
    98     {
       
    99     TRAPD(err, iHttpTransferBase->StartTransferL( aKey ) );
       
   100     if (err != KErrNone)
       
   101         {
       
   102         TransferCompleted(aKey, err);
       
   103         }
       
   104     }
       
   105 void CUpnpTransferBase::CancelTransfer(TInt aKey)
       
   106     {
       
   107     iHttpTransferBase->CancelTransfer( (TAny*) aKey ) ;
       
   108     }
       
   109  
       
   110 // End of File