upnpavcontrolpoint/avcpengine/src/upnpcommand.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     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:  CUpnpCommand
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "upnpcommand.h"
       
    21 #include "upnpavcpmanager.h"
       
    22 #include "upnpavcontrolpoint.h"
       
    23 #include "upnpavcpenginesession.h"
       
    24 // commands
       
    25 #include "upnpdevicelistcommand.h"
       
    26 #include "upnpbrowsecommand.h"
       
    27 #include "upnpdownloadcommand.h"
       
    28 #include "upnpuploadcommand.h"
       
    29 #include "upnpcreatecommand.h"
       
    30 #include "upnpdeletecommand.h"
       
    31 #include "upnpmetadatacommand.h"
       
    32 
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CUpnpCommand::CUpnpCommand
       
    38 // C++ default constructor can NOT contain any code, that
       
    39 // might leae.
       
    40 // -----------------------------------------------------------------------------
       
    41 CUpnpCommand::CUpnpCommand(CUpnpAVCPManager& aAVCPManager, 
       
    42                    CUpnpAVCPEngineSession& aSession, 
       
    43                    const RMessage2& aMessage):
       
    44                    iAVCPManager(aAVCPManager),
       
    45                    iSession(aSession),
       
    46                    iMessage(aMessage)                       
       
    47     {
       
    48     iType = (TAVCPEngineRqst)iMessage.Function();
       
    49     iId = aAVCPManager.NewCommandId();
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CUpnpCommand::BaseConstructL
       
    54 // Symbian 2nd phase constructor can leave.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CUpnpCommand::BaseConstructL()
       
    58     {    
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CUpnpCommand::NewL
       
    63 // Two-phased constructor.
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CUpnpCommand* CUpnpCommand::NewL(CUpnpAVCPManager& aAVCPManager, CUpnpAVCPEngineSession& aSession, const RMessage2& aMessage)
       
    67     {
       
    68     	CUpnpCommand* command = NULL;
       
    69 		switch (aMessage.Function()) 
       
    70 			{  
       
    71 	        case EPrepareDeviceList:	        
       
    72 		        command = CUpnpDeviceListCommand::NewL(aAVCPManager, aSession, aMessage);
       
    73 	        break;
       
    74 	        case EPrepareDirList:
       
    75             case EDirAttributes:          
       
    76             case EFileAttributes:	        
       
    77 		        command = CUpnpBrowseCommand::NewL(aAVCPManager, aSession, aMessage);	        
       
    78 	        break;
       
    79 	        case EGetFile:
       
    80 		        command = CUpnpDownloadCommand::NewL(aAVCPManager, aSession, aMessage);	        
       
    81 	        break;
       
    82 	        case EPutFile:
       
    83 		        command = CUpnpUploadCommand::NewL(aAVCPManager, aSession, aMessage);	        
       
    84 	        break;	        
       
    85 	        case EDeleteFile:
       
    86             case EDeleteDirectory:	        
       
    87 		        command = CUpnpDeleteCommand::NewL(aAVCPManager, aSession, aMessage);	        
       
    88 	        break;	       
       
    89 	        case ECreateFile:
       
    90             case ECreateDirectory:	        
       
    91 		        command = CUpnpCreateCommand::NewL(aAVCPManager, aSession, aMessage);	        
       
    92 	        break;	 	        
       
    93 	        case EPrepareMetadata:
       
    94             case ESetMetadata:                      
       
    95 		        command = CUpnpMetadataCommand::NewL(aAVCPManager, aSession, aMessage);	        
       
    96 	        break;	        
       
    97 			}    
       
    98 
       
    99     return command;
       
   100     }	
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CUpnpCommand::~CUpnpCommand
       
   104 // desctructor
       
   105 // -----------------------------------------------------------------------------
       
   106 //    
       
   107 CUpnpCommand::~CUpnpCommand()
       
   108     {
       
   109         iSession.RemoveCommand(this);
       
   110     }
       
   111     	
       
   112 // -----------------------------------------------------------------------------
       
   113 // CUpnpCommand::Id
       
   114 // -----------------------------------------------------------------------------
       
   115 //	
       
   116 TInt CUpnpCommand::Id() 
       
   117 	{
       
   118 	return iId;
       
   119 	}
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CUpnpCommand::SessionId
       
   123 // -----------------------------------------------------------------------------
       
   124 //	
       
   125 TInt CUpnpCommand::SessionId() 
       
   126 	{
       
   127 	return iSessionId;
       
   128 	}
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // CUpnpCommand::ReadDes8FromMessageLC
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 HBufC8* CUpnpCommand::ReadDes8FromMessageLC(TInt aIndex) 
       
   135 	{
       
   136 	HBufC8* result = NULL;
       
   137     TInt length = iMessage.GetDesLength( aIndex );	    
       
   138     result = HBufC8::NewLC(length);                             
       
   139    	TPtr8 resultPtr = result->Des();
       
   140     iMessage.ReadL( aIndex, resultPtr );     
       
   141 	return result;	
       
   142 	}
       
   143  
       
   144 // -----------------------------------------------------------------------------
       
   145 // CUpnpCommand::ReadDes16FromMessageLC
       
   146 // -----------------------------------------------------------------------------
       
   147 //        
       
   148 HBufC* CUpnpCommand::ReadDes16FromMessageLC(TInt aIndex) 
       
   149 	{
       
   150 	HBufC* result = NULL;
       
   151     TInt length = iMessage.GetDesLength( aIndex );	    
       
   152     result = HBufC::NewLC(length);                             
       
   153    	TPtr resultPtr = result->Des();
       
   154     iMessage.ReadL( aIndex, resultPtr );     
       
   155 	return result;
       
   156 	}
       
   157        
       
   158 // -----------------------------------------------------------------------------
       
   159 // CUpnpCommand::RunError
       
   160 // -----------------------------------------------------------------------------
       
   161 //        
       
   162 void CUpnpCommand::RunError(TInt /*aErrorCode*/)
       
   163 	{
       
   164     if (iMessage.Handle() != 0)
       
   165     	iMessage.Complete(KErrAbort);
       
   166 	delete this;
       
   167 	}        
       
   168 
       
   169 //  End of File