upnpavcontrolpoint/avcpengine/src/upnpdeletecommand.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /** @file
       
     2 * Copyright (c) 2005-2006 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:  CUpnpDeleteCommand
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "upnpdeletecommand.h"
       
    20 
       
    21 #include "upnppathresolver.h"
       
    22 #include "upnppathelement.h"
       
    23 #include "upnpavcpmanager.h"
       
    24 #include "upnpavcontrolpoint.h"
       
    25 
       
    26 
       
    27 #include "upnpavcpenginehelper.h"
       
    28 using namespace UpnpAVCPEngine;
       
    29 
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CUpnpDeleteCommand::NewL
       
    33 // Two-phased constructor.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CUpnpDeleteCommand* CUpnpDeleteCommand::NewL(CUpnpAVCPManager& aAVCPManager, CUpnpAVCPEngineSession& aSession, const RMessage2& aMessage)
       
    37 	{
       
    38     CUpnpDeleteCommand* self = new( ELeave ) CUpnpDeleteCommand(aAVCPManager, aSession, aMessage);
       
    39     
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop( self );
       
    43 
       
    44     return self;   
       
    45 	}	
       
    46   
       
    47 // -----------------------------------------------------------------------------
       
    48 // CUpnpDeleteCommand::ConstructL
       
    49 // Symbian 2nd phase constructor can leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 //   
       
    52 void CUpnpDeleteCommand::ConstructL() 
       
    53 	{
       
    54  	CUpnpCommand::BaseConstructL();
       
    55  	} 
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CUpnpDeleteCommand::CUpnpDeleteCommand
       
    59 // C++ default constructor can NOT contain any code, that
       
    60 // might leave.
       
    61 // -----------------------------------------------------------------------------   
       
    62 //       
       
    63 CUpnpDeleteCommand::CUpnpDeleteCommand(CUpnpAVCPManager& aAVCPManager, 
       
    64                    CUpnpAVCPEngineSession& aSession, 
       
    65                    const RMessage2& aMessage):
       
    66                    CUpnpCommand( aAVCPManager,
       
    67                    		     aSession, 
       
    68                    		     aMessage)
       
    69 	{
       
    70 	}
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CUpnpDeleteCommand::~CUpnpDeleteCommand
       
    74 // desctructor
       
    75 // -----------------------------------------------------------------------------
       
    76 // 
       
    77 CUpnpDeleteCommand::~CUpnpDeleteCommand()
       
    78 	{    
       
    79 	}
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CUpnpDeleteCommand::SessionId
       
    83 // -----------------------------------------------------------------------------
       
    84 // 
       
    85 TInt CUpnpDeleteCommand::SessionId() 
       
    86 	{
       
    87     return CUpnpCommand::SessionId();   
       
    88 	}
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CUpnpDeleteCommand::RunError
       
    92 // -----------------------------------------------------------------------------
       
    93 // 
       
    94 void CUpnpDeleteCommand::RunError(TInt aErrorCode) 
       
    95 	{
       
    96     return CUpnpCommand::RunError(aErrorCode);   
       
    97 	}
       
    98 	
       
    99 // -----------------------------------------------------------------------------
       
   100 // CUpnpDeleteCommand::ExecuteL
       
   101 // -----------------------------------------------------------------------------
       
   102 // 
       
   103 void CUpnpDeleteCommand::ExecuteL()
       
   104 	{
       
   105 	//ASSERT(iType == EDeleteDirectory || iType == EDeleteFile );
       
   106     
       
   107     HBufC8* uuid = NULL;
       
   108     HBufC8* path = NULL;       
       
   109     DEBUGSTRING(("Execute Delete command"));
       
   110             	
       
   111     uuid = ReadDes8FromMessageLC(0);    
       
   112     DEBUGSTRING8(("  uuid: %S",uuid)); 	            	
       
   113     path = ReadDes8FromMessageLC(1);       	         	    		  
       
   114     DEBUGSTRING8(("  path: %S",path)); 
       
   115     
       
   116     iPathResolver = &(iAVCPManager.PathResolverL(*uuid, &iSession));
       
   117     	 
       
   118     iPathResolver->ResolveIdL(*path, *this);
       
   119 
       
   120 	CleanupStack::PopAndDestroy(path);        
       
   121 	CleanupStack::PopAndDestroy(uuid);          
       
   122 	}
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CUpnpDeleteCommand::SetResultL
       
   126 // -----------------------------------------------------------------------------
       
   127 // 
       
   128 void CUpnpDeleteCommand::SetResultL(const RMessage2& /*aMessage*/) 
       
   129 	{
       
   130 	}
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CUpnpDeleteCommand::Interpret
       
   134 // -----------------------------------------------------------------------------
       
   135 // 
       
   136 void CUpnpDeleteCommand::InterpretL(TInt aErrorCode, CUpnpAction* /*aAction*/) 
       
   137 	{
       
   138 	DEBUGSTRING(("Interpret action response %d", aErrorCode));	
       
   139     if (aErrorCode == EHttp200Ok) 
       
   140     	{
       
   141 		iMessage.Complete(KErrNone); 		            
       
   142     	}
       
   143     else 
       
   144     	{
       
   145         iMessage.Complete(KErrAbort); 
       
   146     	}   
       
   147 	delete this;    	
       
   148 	}
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CUpnpDeleteCommand::ResolvedId
       
   152 // -----------------------------------------------------------------------------
       
   153 // 
       
   154 void CUpnpDeleteCommand::ResolvedIdL(TInt aErrCode, CUpnpPathElement* aIdElement)
       
   155 	{    
       
   156     if (aErrCode == KErrNone)  
       
   157     	{        
       
   158     	//remove from remote MS
       
   159         iSessionId = iAVCPManager.CdsDestroyObjectActionL(iPathResolver->UUID(), aIdElement->Id());    
       
   160         iAVCPManager.RegisterForAction(*this);              
       
   161     	// remove from local cache
       
   162     	iPathResolver->RemoveElementD(aIdElement);     	
       
   163     	}
       
   164     else 
       
   165     	{
       
   166         iMessage.Complete(KErrNotFound);
       
   167         delete this;
       
   168     	}
       
   169 	}