diff -r 6369bfd1b60d -r 08b5eae9f9ff upnpavcontrolpoint/avcpengine/src/upnpcreatecommand.cpp --- a/upnpavcontrolpoint/avcpengine/src/upnpcreatecommand.cpp Mon Nov 01 13:44:24 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,228 +0,0 @@ -/** @file -* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: CUpnpCreateCommand -* -*/ - - -#include "upnpcreatecommand.h" - -#include "upnppathresolver.h" -#include "upnppathelement.h" -#include "upnpavcpmanager.h" -#include "upnpavcontrolpoint.h" - -#include "upnpavcpenginehelper.h" -using namespace UpnpAVCPEngine; -#include "upnpstring.h" - - -_LIT8(KCreateFileTemplate, - " \ - \ - %S \ - object.item \ - \ - \ - "); - -_LIT8(KCreateDirTemplate, -" \ - \ - %S \ - object.container \ - \ - "); - - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::NewL -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CUpnpCreateCommand* CUpnpCreateCommand::NewL(CUpnpAVCPManager& aAVCPManager, CUpnpAVCPEngineSession& aSession, const RMessage2& aMessage) - { - CUpnpCreateCommand* self = new( ELeave ) CUpnpCreateCommand(aAVCPManager, aSession, aMessage); - - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - - return self; - } - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::ConstructL -// Symbian 2nd phase constructor can leave. -// ----------------------------------------------------------------------------- -// -void CUpnpCreateCommand::ConstructL() - { - CUpnpCommand::BaseConstructL(); - } - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::CUpnpCreateCommand -// C++ default constructor can NOT contain any code, that -// might leave. -// ----------------------------------------------------------------------------- -// -CUpnpCreateCommand::CUpnpCreateCommand(CUpnpAVCPManager& aAVCPManager, - CUpnpAVCPEngineSession& aSession, - const RMessage2& aMessage): - CUpnpCommand( aAVCPManager, - aSession, - aMessage) - { - } - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::~CUpnpCreateCommand -// desctructor -// ----------------------------------------------------------------------------- -// -CUpnpCreateCommand::~CUpnpCreateCommand() - { - delete iObjectId; - delete iTargetName; - } - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::SessionId -// ----------------------------------------------------------------------------- -// -TInt CUpnpCreateCommand::SessionId() - { - return CUpnpCommand::SessionId(); - } - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::RunError -// ----------------------------------------------------------------------------- -// -void CUpnpCreateCommand::RunError(TInt aErrorCode) - { - return CUpnpCommand::RunError(aErrorCode); - } - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::ExecuteL -// ----------------------------------------------------------------------------- -// -void CUpnpCreateCommand::ExecuteL() - { - //ASSERT(iType == ECreateDirectory || iType == ECreateFile ); - - HBufC8* uuid = NULL; - HBufC8* path = NULL; - DEBUGSTRING(("Execute Create command ")); - uuid = ReadDes8FromMessageLC(0); - DEBUGSTRING8((" uuid: %S",uuid)); - path = ReadDes8FromMessageLC(1); - DEBUGSTRING8((" path: %S",path)); - - TPtr8 pathPtr = path->Des(); - // removes also last element of path - iTargetName = GetLastPathElementL(pathPtr); - - iPathResolver = &(iAVCPManager.PathResolverL(*uuid, &iSession)); - iPathResolver->ResolveIdL(*path, *this); - - CleanupStack::PopAndDestroy(path); - CleanupStack::PopAndDestroy(uuid); - } - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::SetResultL -// ----------------------------------------------------------------------------- -// -void CUpnpCreateCommand::SetResultL(const RMessage2& /*aMessage*/) - { - } - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::Interpret -// ----------------------------------------------------------------------------- -// -void CUpnpCreateCommand::InterpretL(TInt aErrorCode, CUpnpAction* aAction) - { - DEBUGSTRING(("Interpret action response %d", aErrorCode)); - if (aErrorCode == EHttp200Ok ) - { - if (iType == ECreateDirectory) - { - iMessage.Complete(KErrNone); - } - else - { - if(iPathResolver->BrowseCreateObjectL( aAction->ArgumentValue( KResult ))) - { - iMessage.Complete(KErrNone); - } - else - { - iMessage.Complete(KErrAbort); - } - } - - } - else - { - iMessage.Complete(KErrAbort); - } - delete this; - } - -// ----------------------------------------------------------------------------- -// CUpnpCreateCommand::ResolvedId -// ----------------------------------------------------------------------------- -// -void CUpnpCreateCommand::ResolvedIdL(TInt aErrCode, CUpnpPathElement* aIdElement) - { - if (aErrCode == KErrNone) - { - iElement = aIdElement; - iObjectId = aIdElement->Id().AllocL(); - HBufC8* createMsg; - if (iType == ECreateDirectory ) - { - createMsg = HBufC8::NewLC(KCreateDirTemplate().Length() + iObjectId->Length() + iTargetName->Length()); - createMsg->Des().AppendFormat(KCreateDirTemplate, iObjectId, iTargetName); - } - else - { - createMsg = HBufC8::NewLC(KCreateFileTemplate().Length() + iObjectId->Length() + iTargetName->Length()); - createMsg->Des().AppendFormat(KCreateFileTemplate, iObjectId, iTargetName); - } - HBufC8* encoded = UpnpString::EncodeXmlStringL( createMsg ); - CleanupStack::PopAndDestroy(createMsg); - CleanupStack::PushL(encoded); - - iSessionId = iAVCPManager.CdsCreateObjectActionL(iPathResolver->UUID(), *iObjectId, *encoded); - iAVCPManager.RegisterForAction(*this); - - CleanupStack::PopAndDestroy(encoded); - - } - else - { - iMessage.Complete(KErrNotFound); - delete this; - } - - }